From a519ed25806fefc2d0844be2f266f4dd90ca88fd Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 29 Aug 2019 10:01:59 -0400 Subject: [PATCH] memory stored pinProtectedKey --- jslib | 2 +- src/app/accounts/settings.component.ts | 17 +++++++++-------- src/app/app.component.ts | 1 - 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/jslib b/jslib index 99d56d936f..b74ee7b3ee 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit 99d56d936fdebc99994ce5089e8f063729a2e0ec +Subproject commit b74ee7b3ee823a820854623cc32c8522a09e9f4d diff --git a/src/app/accounts/settings.component.ts b/src/app/accounts/settings.component.ts index 68eff377ab..a63f68dbcd 100644 --- a/src/app/accounts/settings.component.ts +++ b/src/app/accounts/settings.component.ts @@ -149,16 +149,17 @@ export class SettingsComponent implements OnInit { masterPassOnRestart = (document.getElementById('master-pass-restart') as HTMLInputElement).checked; } if (pin != null && pin.trim() !== '') { + const kdf = await this.userService.getKdf(); + const kdfIterations = await this.userService.getKdfIterations(); + const email = await this.userService.getEmail(); + const pinKey = await this.cryptoService.makePinKey(pin, email, kdf, kdfIterations); + const key = await this.cryptoService.getKey(); + const pinProtectedKey = await this.cryptoService.encrypt(key.key, pinKey); if (masterPassOnRestart) { const encPin = await this.cryptoService.encrypt(pin); await this.storageService.save(ConstantsService.protectedPin, encPin.encryptedString); + this.lockService.pinProtectedKey = pinProtectedKey; } else { - const kdf = await this.userService.getKdf(); - const kdfIterations = await this.userService.getKdfIterations(); - const email = await this.userService.getEmail(); - const pinKey = await this.cryptoService.makePinKey(pin, email, kdf, kdfIterations); - const key = await this.cryptoService.getKey(); - const pinProtectedKey = await this.cryptoService.encrypt(key.key, pinKey); await this.storageService.save(ConstantsService.pinProtectedKey, pinProtectedKey.encryptedString); } } else { @@ -166,8 +167,8 @@ export class SettingsComponent implements OnInit { } } if (!this.pin) { - await this.storageService.remove(ConstantsService.pinProtectedKey); - await this.storageService.remove(ConstantsService.protectedPin); + await this.cryptoService.clearPinProtectedKey(); + await this.lockService.clear(); } } diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 983d15f027..54a8f62b42 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -228,7 +228,6 @@ export class AppComponent implements OnInit { this.stateService.purge(), ]); - this.lockService.pinLocked = false; this.searchService.clearIndex(); this.authService.logOut(async () => { this.analytics.eventTrack.next({ action: 'Logged Out' });