soft lock with PIN
This commit is contained in:
parent
2c91a2004c
commit
1002991022
2
jslib
2
jslib
|
@ -1 +1 @@
|
||||||
Subproject commit f67fac3eebc21b8935a54a28b7a21152c8513322
|
Subproject commit a19a30ffed177e18d6e64801066510bc983a3e8d
|
|
@ -82,7 +82,8 @@ export class SettingsComponent implements OnInit {
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
this.showMinToTray = this.platformUtilsService.getDevice() === DeviceType.WindowsDesktop;
|
this.showMinToTray = this.platformUtilsService.getDevice() === DeviceType.WindowsDesktop;
|
||||||
this.lockOption = await this.storageService.get<number>(ConstantsService.lockOptionKey);
|
this.lockOption = await this.storageService.get<number>(ConstantsService.lockOptionKey);
|
||||||
this.pin = await this.lockService.isPinLockSet();
|
const pinSet = await this.lockService.isPinLockSet();
|
||||||
|
this.pin = pinSet[0] || pinSet[1];
|
||||||
this.disableFavicons = await this.storageService.get<boolean>(ConstantsService.disableFaviconKey);
|
this.disableFavicons = await this.storageService.get<boolean>(ConstantsService.disableFaviconKey);
|
||||||
this.enableMinToTray = await this.storageService.get<boolean>(ElectronConstants.enableMinimizeToTrayKey);
|
this.enableMinToTray = await this.storageService.get<boolean>(ElectronConstants.enableMinimizeToTrayKey);
|
||||||
this.enableCloseToTray = await this.storageService.get<boolean>(ElectronConstants.enableCloseToTrayKey);
|
this.enableCloseToTray = await this.storageService.get<boolean>(ElectronConstants.enableCloseToTrayKey);
|
||||||
|
@ -98,13 +99,34 @@ export class SettingsComponent implements OnInit {
|
||||||
|
|
||||||
async updatePin() {
|
async updatePin() {
|
||||||
if (this.pin) {
|
if (this.pin) {
|
||||||
const pin = await swal({
|
const div = document.createElement('div');
|
||||||
|
const label = document.createElement('label');
|
||||||
|
label.className = 'checkbox';
|
||||||
|
const checkboxText = document.createElement('span');
|
||||||
|
const restartText = document.createTextNode(this.i18nService.t('lockWithMasterPassOnRestart'));
|
||||||
|
checkboxText.appendChild(restartText);
|
||||||
|
label.innerHTML = '<input type="checkbox" id="master-pass-restart" checked>';
|
||||||
|
label.appendChild(checkboxText);
|
||||||
|
div.innerHTML = '<input type="text" class="swal-content__input" id="pin-val">';
|
||||||
|
(div.querySelector('#pin-val') as HTMLInputElement).placeholder = this.i18nService.t('pin');
|
||||||
|
div.appendChild(label);
|
||||||
|
|
||||||
|
const submitted = await swal({
|
||||||
text: this.i18nService.t('setYourPinCode'),
|
text: this.i18nService.t('setYourPinCode'),
|
||||||
content: { element: 'input' },
|
content: { element: div },
|
||||||
buttons: [this.i18nService.t('cancel'), this.i18nService.t('submit')],
|
buttons: [this.i18nService.t('cancel'), this.i18nService.t('submit')],
|
||||||
});
|
});
|
||||||
|
let pin: string = null;
|
||||||
|
let masterPassOnRestart: boolean = null;
|
||||||
|
if (submitted) {
|
||||||
|
pin = (document.getElementById('pin-val') as HTMLInputElement).value;
|
||||||
|
masterPassOnRestart = (document.getElementById('master-pass-restart') as HTMLInputElement).checked;
|
||||||
|
}
|
||||||
if (pin != null && pin.trim() !== '') {
|
if (pin != null && pin.trim() !== '') {
|
||||||
|
if (masterPassOnRestart) {
|
||||||
|
const encPin = await this.cryptoService.encrypt(pin);
|
||||||
|
await this.storageService.save(ConstantsService.protectedPin, encPin.encryptedString);
|
||||||
|
} else {
|
||||||
const kdf = await this.userService.getKdf();
|
const kdf = await this.userService.getKdf();
|
||||||
const kdfIterations = await this.userService.getKdfIterations();
|
const kdfIterations = await this.userService.getKdfIterations();
|
||||||
const email = await this.userService.getEmail();
|
const email = await this.userService.getEmail();
|
||||||
|
@ -112,12 +134,14 @@ export class SettingsComponent implements OnInit {
|
||||||
const key = await this.cryptoService.getKey();
|
const key = await this.cryptoService.getKey();
|
||||||
const pinProtectedKey = await this.cryptoService.encrypt(key.key, pinKey);
|
const pinProtectedKey = await this.cryptoService.encrypt(key.key, pinKey);
|
||||||
await this.storageService.save(ConstantsService.pinProtectedKey, pinProtectedKey.encryptedString);
|
await this.storageService.save(ConstantsService.pinProtectedKey, pinProtectedKey.encryptedString);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.pin = false;
|
this.pin = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!this.pin) {
|
if (!this.pin) {
|
||||||
await this.storageService.remove(ConstantsService.pinProtectedKey);
|
await this.storageService.remove(ConstantsService.pinProtectedKey);
|
||||||
|
await this.storageService.remove(ConstantsService.protectedPin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ export class AppComponent implements OnInit {
|
||||||
this.logOut(!!message.expired);
|
this.logOut(!!message.expired);
|
||||||
break;
|
break;
|
||||||
case 'lockVault':
|
case 'lockVault':
|
||||||
await this.lockService.lock();
|
await this.lockService.lock(true);
|
||||||
break;
|
break;
|
||||||
case 'locked':
|
case 'locked':
|
||||||
this.router.navigate(['lock'], { queryParams: { refresh: true } });
|
this.router.navigate(['lock'], { queryParams: { refresh: true } });
|
||||||
|
@ -175,7 +175,7 @@ export class AppComponent implements OnInit {
|
||||||
private async updateAppMenu() {
|
private async updateAppMenu() {
|
||||||
this.messagingService.send('updateAppMenu', {
|
this.messagingService.send('updateAppMenu', {
|
||||||
isAuthenticated: await this.userService.isAuthenticated(),
|
isAuthenticated: await this.userService.isAuthenticated(),
|
||||||
isLocked: !(await this.cryptoService.hasKey()),
|
isLocked: await this.lockService.isLocked(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,8 +192,10 @@ export class AppComponent implements OnInit {
|
||||||
this.folderService.clear(userId),
|
this.folderService.clear(userId),
|
||||||
this.collectionService.clear(userId),
|
this.collectionService.clear(userId),
|
||||||
this.passwordGenerationService.clear(),
|
this.passwordGenerationService.clear(),
|
||||||
|
this.lockService.clear(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
this.lockService.pinLocked = false;
|
||||||
this.searchService.clearIndex();
|
this.searchService.clearIndex();
|
||||||
this.authService.logOut(async () => {
|
this.authService.logOut(async () => {
|
||||||
this.analytics.eventTrack.next({ action: 'Logged Out' });
|
this.analytics.eventTrack.next({ action: 'Logged Out' });
|
||||||
|
|
|
@ -113,7 +113,7 @@ const authService = new AuthService(cryptoService, apiService,
|
||||||
const exportService = new ExportService(folderService, cipherService, apiService);
|
const exportService = new ExportService(folderService, cipherService, apiService);
|
||||||
const auditService = new AuditService(cryptoFunctionService, apiService);
|
const auditService = new AuditService(cryptoFunctionService, apiService);
|
||||||
const notificationsService = new NotificationsService(userService, syncService, appIdService,
|
const notificationsService = new NotificationsService(userService, syncService, appIdService,
|
||||||
apiService, cryptoService, async () => messagingService.send('logout', { expired: true }));
|
apiService, lockService, async () => messagingService.send('logout', { expired: true }));
|
||||||
const environmentService = new EnvironmentService(apiService, storageService, notificationsService);
|
const environmentService = new EnvironmentService(apiService, storageService, notificationsService);
|
||||||
|
|
||||||
const analytics = new Analytics(window, () => isDev(), platformUtilsService, storageService, appIdService);
|
const analytics = new Analytics(window, () => isDev(), platformUtilsService, storageService, appIdService);
|
||||||
|
|
|
@ -1188,5 +1188,8 @@
|
||||||
},
|
},
|
||||||
"yourVaultIsLockedPinCode": {
|
"yourVaultIsLockedPinCode": {
|
||||||
"message": "Your vault is locked. Verify your PIN code to continue."
|
"message": "Your vault is locked. Verify your PIN code to continue."
|
||||||
|
},
|
||||||
|
"lockWithMasterPassOnRestart": {
|
||||||
|
"message": "Lock with master password on restart"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,6 +106,21 @@ $fa-font-path: "~font-awesome/fonts";
|
||||||
color: themed('textColor');
|
color: themed('textColor');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.swal-content {
|
||||||
|
font-size: $font-size-base;
|
||||||
|
|
||||||
|
label.checkbox {
|
||||||
|
margin-top: 10px;
|
||||||
|
display: flex;
|
||||||
|
text-align: left;
|
||||||
|
align-items: top;
|
||||||
|
|
||||||
|
input {
|
||||||
|
margin: 3px 5px 0 1px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.swal-text {
|
.swal-text {
|
||||||
font-size: $font-size-base;
|
font-size: $font-size-base;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue