1
0
mirror of https://github.com/bitwarden/browser synced 2026-01-05 18:13:26 +00:00

Use sync instead of token to manage emailVerified (#344)

This commit is contained in:
Thomas Rittson
2021-04-15 07:00:49 +10:00
committed by GitHub
parent 92df633040
commit 66eec2b022
4 changed files with 19 additions and 4 deletions

View File

@@ -288,6 +288,7 @@ export class SyncService implements SyncServiceAbstraction {
await this.cryptoService.setEncPrivateKey(response.privateKey);
await this.cryptoService.setOrgKeys(response.organizations);
await this.userService.setSecurityStamp(response.securityStamp);
await this.userService.setEmailVerified(response.emailVerified);
const organizations: { [id: string]: OrganizationData; } = {};
response.organizations.forEach(o => {

View File

@@ -14,6 +14,7 @@ const Keys = {
kdf: 'kdf',
kdfIterations: 'kdfIterations',
organizationsPrefix: 'organizations_',
emailVerified: 'emailVerified',
};
export class UserService implements UserServiceAbstraction {
@@ -22,6 +23,7 @@ export class UserService implements UserServiceAbstraction {
private stamp: string;
private kdf: KdfType;
private kdfIterations: number;
private emailVerified: boolean;
constructor(private tokenService: TokenService, private storageService: StorageService) { }
@@ -44,6 +46,11 @@ export class UserService implements UserServiceAbstraction {
return this.storageService.save(Keys.stamp, stamp);
}
setEmailVerified(emailVerified: boolean) {
this.emailVerified = emailVerified;
return this.storageService.save(Keys.emailVerified, emailVerified);
}
async getUserId(): Promise<string> {
if (this.userId == null) {
this.userId = await this.storageService.get<string>(Keys.userId);
@@ -79,6 +86,13 @@ export class UserService implements UserServiceAbstraction {
return this.kdfIterations;
}
async getEmailVerified(): Promise<boolean> {
if (this.emailVerified == null) {
this.emailVerified = await this.storageService.get<boolean>(Keys.emailVerified);
}
return this.emailVerified;
}
async clear(): Promise<any> {
const userId = await this.getUserId();