Browse Source

dont set keys if not there on sso (#152)

* dont set keys if not there on sso

* a comment
PS-589-2fa-device-verification-settings
Kyle Spearrin 5 years ago committed by GitHub
parent
commit
9957125d3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 30
      src/services/auth.service.ts

30
src/services/auth.service.ts

@ -308,21 +308,25 @@ export class AuthService implements AuthServiceAbstraction {
if (hashedPassword != null) { if (hashedPassword != null) {
await this.cryptoService.setKeyHash(hashedPassword); await this.cryptoService.setKeyHash(hashedPassword);
} }
await this.cryptoService.setEncKey(tokenResponse.key);
// Skip this step during SSO new user flow. No key is returned from server.
// User doesn't have a key pair yet (old account), let's generate one for them if (code == null || tokenResponse.key != null) {
if (tokenResponse.privateKey == null) { await this.cryptoService.setEncKey(tokenResponse.key);
try {
const keyPair = await this.cryptoService.makeKeyPair(); // User doesn't have a key pair yet (old account), let's generate one for them
await this.apiService.postAccountKeys(new KeysRequest(keyPair[0], keyPair[1].encryptedString)); if (tokenResponse.privateKey == null) {
tokenResponse.privateKey = keyPair[1].encryptedString; try {
} catch (e) { const keyPair = await this.cryptoService.makeKeyPair();
// tslint:disable-next-line await this.apiService.postAccountKeys(new KeysRequest(keyPair[0], keyPair[1].encryptedString));
console.error(e); tokenResponse.privateKey = keyPair[1].encryptedString;
} catch (e) {
// tslint:disable-next-line
console.error(e);
}
} }
}
await this.cryptoService.setEncPrivateKey(tokenResponse.privateKey); await this.cryptoService.setEncPrivateKey(tokenResponse.privateKey);
}
} }
if (this.vaultTimeoutService != null) { if (this.vaultTimeoutService != null) {

Loading…
Cancel
Save