Skip to content

Commit 249d161

Browse files
committed
fix: [workaround] allow authenticated site requests as any provided user
1 parent 269250e commit 249d161

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/shared/experience/expSite.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,20 @@ export class ExperienceSite {
6666
* @returns sid token for proxied site requests
6767
*/
6868
public async setupAuth(): Promise<string> {
69-
let sidToken = ''; // Default to guest user access only
69+
let sidToken = '';
70+
// Default to guest user access if specified
71+
if (process.env.SITE_GUEST_ACCESS === 'true') return sidToken;
7072

71-
// Use environment variable for now if users want to just have guest access only
72-
if (process.env.SITE_GUEST_ACCESS !== 'true') {
73-
try {
74-
const networkId = await this.getNetworkId();
75-
sidToken = await this.getNewSidToken(networkId);
76-
} catch (e) {
77-
// eslint-disable-next-line no-console
78-
console.error('Failed to establish authentication for site', e);
79-
}
73+
// Use a provided token if specified in environment variables
74+
if (process.env.SID_TOKEN) return process.env.SID_TOKEN;
75+
76+
// Otherwise attempt to generate one based on the currently authenticated admin user
77+
try {
78+
const networkId = await this.getNetworkId();
79+
sidToken = await this.getNewSidToken(networkId);
80+
} catch (e) {
81+
// eslint-disable-next-line no-console
82+
console.error('Failed to establish authentication for site', e);
8083
}
8184

8285
return sidToken;

0 commit comments

Comments
 (0)