mirror of
https://github.com/bitwarden/jslib
synced 2026-01-07 11:03:13 +00:00
[bug] Ensure keys and tokens load and save to the right locations for web
This commit is contained in:
@@ -30,6 +30,7 @@ export abstract class StateService {
|
||||
addAccount: (account: Account) => Promise<void>;
|
||||
setActiveUser: (userId: string) => Promise<void>;
|
||||
clean: (options?: StorageOptions) => Promise<void>;
|
||||
init: () => Promise<void>;
|
||||
|
||||
getAccessToken: (options?: StorageOptions) => Promise<string>;
|
||||
setAccessToken: (value: string, options?: StorageOptions) => Promise<void>;
|
||||
|
||||
@@ -126,8 +126,7 @@ export class Account {
|
||||
convertAccountToKeyConnector: boolean;
|
||||
usesKeyConnector: boolean;
|
||||
enableFullWidth: boolean;
|
||||
|
||||
private hasPremiumPersonally: boolean;
|
||||
hasPremiumPersonally: boolean;
|
||||
|
||||
constructor(userId: string, userEmail: string,
|
||||
kdfType: KdfType, kdfIterations: number,
|
||||
@@ -145,39 +144,8 @@ export class Account {
|
||||
this.hasPremiumPersonally = hasPremium;
|
||||
}
|
||||
|
||||
get isAuthenticated(): boolean {
|
||||
if (!this.accessToken) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.userId != null;
|
||||
}
|
||||
|
||||
get canAccessPremium(): boolean {
|
||||
if (!this.isAuthenticated) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.hasPremiumPersonally || this.hasPremiumThroughOrganization;
|
||||
}
|
||||
|
||||
get serverUrl(): string {
|
||||
return this.environmentUrls?.base ?? 'bitwarden.com';
|
||||
}
|
||||
|
||||
private get hasPremiumThroughOrganization(): boolean {
|
||||
if (this.organizations == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const id of Object.keys(this.organizations)) {
|
||||
const o = this.organizations[id];
|
||||
if (o.enabled && o.usersGetPremium && !o.isProviderUser) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user