mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-05 17:58:55 +00:00
studio rollout domain check and session flag
This commit is contained in:
1 parent
9a40118974
commit
2abe1c1a46
3 files changed
+31
No files matched your search
@@ -18,6 +18,9 @@ export interface UserInfo {
|
||||
display_name: string,
|
||||
email_gravatar_hash: string,
|
||||
|
||||
// Rollout feature flags
|
||||
can_access_studio: boolean,
|
||||
|
||||
// Usage
|
||||
can_use_tts: boolean,
|
||||
can_use_w2l: boolean,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { GetSessionInfo, GetSessionInfoIsOk, SessionInfoSuccessResponse } from '../api/session/GetSessionInfo'
|
||||
import { StudioRolloutHostnameAllowed } from '../utils/StudioRolloutHostnameAllowed';
|
||||
|
||||
// A lot of the APIs return null or leave values absent.
|
||||
// I need to pick a single strategy and stick with it.
|
||||
@@ -44,6 +45,14 @@ export class SessionWrapper {
|
||||
return this.sessionStateResponse?.logged_in || false;
|
||||
}
|
||||
|
||||
// Feature flag rollout for Storyteller Studio
|
||||
// This depends on the domain name and the backend.
|
||||
public canAccessStudio() : boolean {
|
||||
const hostnameAllowed = StudioRolloutHostnameAllowed();
|
||||
const userAllowed = this.sessionStateResponse?.user?.can_access_studio || false;
|
||||
return hostnameAllowed && userAllowed;
|
||||
}
|
||||
|
||||
// Username is all lowercase
|
||||
public getUsername() : string | undefined {
|
||||
return this.sessionStateResponse?.user?.username;
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
|
||||
// Check if hostname is allowed to display studio features.
|
||||
// This should allow more frequently landing against production.
|
||||
export function StudioRolloutHostnameAllowed() : boolean {
|
||||
const allowed = StudioRolloutHostnameCheck();
|
||||
return allowed;
|
||||
}
|
||||
|
||||
function StudioRolloutHostnameCheck() : boolean {
|
||||
// Do not allow "production" or "staging" domains to use studio yet.
|
||||
// Other domains (local development and feature branches) are allowed.
|
||||
switch (window.location.hostname) {
|
||||
case 'fakeyou.com':
|
||||
case 'storyteller.ai':
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user