Skip to content
This repository has been archived by the owner on Jun 17, 2022. It is now read-only.

Commit

Permalink
getAll ciphers FromApiForOrganization
Browse files Browse the repository at this point in the history
  • Loading branch information
kspearrin committed Dec 14, 2018
1 parent e559263 commit e10523c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/abstractions/cipher.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export abstract class CipherService {
getAllDecrypted: () => Promise<CipherView[]>;
getAllDecryptedForGrouping: (groupingId: string, folder?: boolean) => Promise<CipherView[]>;
getAllDecryptedForUrl: (url: string, includeOtherTypes?: CipherType[]) => Promise<CipherView[]>;
getAllFromApiForOrganization: (organizationId: string) => Promise<CipherView[]>;
getLastUsedForUrl: (url: string) => Promise<CipherView>;
updateLastUsedDate: (id: string) => Promise<void>;
saveNeverDomain: (domain: string) => Promise<void>;
Expand Down
18 changes: 18 additions & 0 deletions src/services/cipher.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,24 @@ export class CipherService implements CipherServiceAbstraction {
});
}

async getAllFromApiForOrganization(organizationId: string): Promise<CipherView[]> {
const ciphers = await this.apiService.getCiphersOrganization(organizationId);
if (ciphers != null && ciphers.data != null && ciphers.data.length) {
const decCiphers: CipherView[] = [];
const promises: any[] = [];
ciphers.data.forEach((r) => {
const data = new CipherData(r);
const cipher = new Cipher(data);
promises.push(cipher.decrypt().then((c) => decCiphers.push(c)));
});
await Promise.all(promises);
decCiphers.sort(this.getLocaleSortingFunction());
return decCiphers;
} else {
return [];
}
}

async getLastUsedForUrl(url: string): Promise<CipherView> {
const ciphers = await this.getAllDecryptedForUrl(url);
if (ciphers.length === 0) {
Expand Down

0 comments on commit e10523c

Please sign in to comment.