1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-15 07:43:35 +00:00

[SSO] Set password auto enroll update (#472)

* [SSO/Auto Enroll] Set Password enrolls new user

* Fixed typo

* Linter updates

* Cleanup // Constructor for SetPasswordRequest
This commit is contained in:
Vincent Salucci
2021-09-03 14:49:03 -05:00
committed by GitHub
parent 6c9485596c
commit ef743ea8ca
4 changed files with 83 additions and 21 deletions

View File

@@ -21,6 +21,7 @@ export abstract class UserService {
isAuthenticated: () => Promise<boolean>;
canAccessPremium: () => Promise<boolean>;
getOrganization: (id: string) => Promise<Organization>;
getOrganizationByIdentifier: (identifier: string) => Promise<Organization>;
getAllOrganizations: () => Promise<Organization[]>;
replaceOrganizations: (organizations: { [id: string]: OrganizationData; }) => Promise<any>;
clearOrganizations: (userId: string) => Promise<any>;

View File

@@ -10,4 +10,15 @@ export class SetPasswordRequest {
kdf: KdfType;
kdfIterations: number;
orgIdentifier: string;
constructor(masterPasswordHash: string, key: string, masterPasswordHint: string, kdf: KdfType,
kdfIterations: number, orgIdentifier: string, keys: KeysRequest) {
this.masterPasswordHash = masterPasswordHash;
this.key = key;
this.masterPasswordHint = masterPasswordHint;
this.kdf = kdf;
this.kdfIterations = kdfIterations;
this.orgIdentifier = orgIdentifier;
this.keys = keys;
}
}

View File

@@ -166,6 +166,15 @@ export class UserService implements UserServiceAbstraction {
return new Organization(organizations[id]);
}
async getOrganizationByIdentifier(identifier: string): Promise<Organization> {
const organizations = await this.getAllOrganizations();
if (organizations == null || organizations.length === 0) {
return null;
}
return organizations.find(o => o.identifier === identifier);
}
async getAllOrganizations(): Promise<Organization[]> {
const userId = await this.getUserId();
const organizations = await this.storageService.get<{ [id: string]: OrganizationData; }>(