mirror of
https://github.com/bitwarden/browser
synced 2025-01-01 12:47:57 +01:00
move sso properties to globalstate (#583)
* move sso properties to globalstate * whitespace * npm prettier changes
This commit is contained in:
parent
a8168d6ee7
commit
59a5300458
@ -95,9 +95,6 @@ export class AccountProfile {
|
||||
hasPremiumPersonally?: boolean;
|
||||
lastActive?: number;
|
||||
lastSync?: string;
|
||||
ssoCodeVerifier?: string;
|
||||
ssoOrganizationIdentifier?: string;
|
||||
ssoState?: string;
|
||||
userId?: string;
|
||||
usesKeyConnector?: boolean;
|
||||
keyHash?: string;
|
||||
|
@ -5,6 +5,9 @@ export class GlobalState {
|
||||
locale?: string;
|
||||
openAtLogin?: boolean;
|
||||
organizationInvitation?: any;
|
||||
ssoCodeVerifier?: string;
|
||||
ssoOrganizationIdentifier?: string;
|
||||
ssoState?: string;
|
||||
rememberedEmail?: string;
|
||||
theme?: string;
|
||||
window?: Map<string, any> = new Map<string, any>();
|
||||
|
@ -1874,46 +1874,54 @@ export class StateService implements StateServiceAbstraction {
|
||||
}
|
||||
|
||||
async getSsoCodeVerifier(options?: StorageOptions): Promise<string> {
|
||||
return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))
|
||||
?.profile?.ssoCodeVerifier;
|
||||
return (
|
||||
await this.getGlobals(this.reconcileOptions(options, await this.defaultOnDiskOptions()))
|
||||
)?.ssoCodeVerifier;
|
||||
}
|
||||
|
||||
async setSsoCodeVerifier(value: string, options?: StorageOptions): Promise<void> {
|
||||
const account = await this.getAccount(
|
||||
this.reconcileOptions(options, this.defaultInMemoryOptions)
|
||||
const globals = await this.getGlobals(
|
||||
this.reconcileOptions(options, await this.defaultOnDiskOptions())
|
||||
);
|
||||
globals.ssoCodeVerifier = value;
|
||||
await this.saveGlobals(
|
||||
globals,
|
||||
this.reconcileOptions(options, await this.defaultOnDiskOptions())
|
||||
);
|
||||
account.profile.ssoCodeVerifier = value;
|
||||
await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions));
|
||||
}
|
||||
|
||||
async getSsoOrgIdentifier(options?: StorageOptions): Promise<string> {
|
||||
return (
|
||||
await this.getAccount(this.reconcileOptions(options, await this.defaultOnDiskLocalOptions()))
|
||||
)?.profile?.ssoOrganizationIdentifier;
|
||||
await this.getGlobals(this.reconcileOptions(options, await this.defaultOnDiskLocalOptions()))
|
||||
)?.ssoOrganizationIdentifier;
|
||||
}
|
||||
|
||||
async setSsoOrganizationIdentifier(value: string, options?: StorageOptions): Promise<void> {
|
||||
const account = await this.getAccount(
|
||||
const globals = await this.getGlobals(
|
||||
this.reconcileOptions(options, await this.defaultOnDiskLocalOptions())
|
||||
);
|
||||
account.profile.ssoOrganizationIdentifier = value;
|
||||
await this.saveAccount(
|
||||
account,
|
||||
globals.ssoOrganizationIdentifier = value;
|
||||
await this.saveGlobals(
|
||||
globals,
|
||||
this.reconcileOptions(options, await this.defaultOnDiskLocalOptions())
|
||||
);
|
||||
}
|
||||
|
||||
async getSsoState(options?: StorageOptions): Promise<string> {
|
||||
return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))
|
||||
?.profile?.ssoState;
|
||||
return (
|
||||
await this.getGlobals(this.reconcileOptions(options, await this.defaultOnDiskOptions()))
|
||||
)?.ssoState;
|
||||
}
|
||||
|
||||
async setSsoState(value: string, options?: StorageOptions): Promise<void> {
|
||||
const account = await this.getAccount(
|
||||
this.reconcileOptions(options, this.defaultInMemoryOptions)
|
||||
const globals = await this.getGlobals(
|
||||
this.reconcileOptions(options, await this.defaultOnDiskOptions())
|
||||
);
|
||||
globals.ssoState = value;
|
||||
await this.saveGlobals(
|
||||
globals,
|
||||
this.reconcileOptions(options, await this.defaultOnDiskOptions())
|
||||
);
|
||||
account.profile.ssoState = value;
|
||||
await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions));
|
||||
}
|
||||
|
||||
async getTheme(options?: StorageOptions): Promise<string> {
|
||||
|
@ -192,6 +192,15 @@ export class StateMigrationService {
|
||||
),
|
||||
openAtLogin: await this.storageService.get<boolean>(v1Keys.openAtLogin, options),
|
||||
organizationInvitation: await this.storageService.get<string>("", options),
|
||||
ssoCodeVerifier: await this.storageService.get<string>(
|
||||
v1Keys.ssoCodeVerifier,
|
||||
options
|
||||
),
|
||||
ssoOrganizationIdentifier: await this.storageService.get<string>(
|
||||
v1Keys.ssoIdentifier,
|
||||
options
|
||||
),
|
||||
ssoState: null,
|
||||
rememberedEmail: await this.storageService.get<string>(
|
||||
v1Keys.rememberedEmail,
|
||||
options
|
||||
@ -327,15 +336,6 @@ export class StateMigrationService {
|
||||
keyHash: await this.storageService.get<string>(v1Keys.keyHash, options),
|
||||
lastActive: await this.storageService.get<number>(v1Keys.lastActive, options),
|
||||
lastSync: null,
|
||||
ssoCodeVerifier: await this.storageService.get<string>(
|
||||
v1Keys.ssoCodeVerifier,
|
||||
options
|
||||
),
|
||||
ssoOrganizationIdentifier: await this.storageService.get<string>(
|
||||
v1Keys.ssoIdentifier,
|
||||
options
|
||||
),
|
||||
ssoState: null,
|
||||
userId: userId,
|
||||
usesKeyConnector: null,
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user