mirror of
https://github.com/bitwarden/jslib
synced 2025-12-21 10:43:23 +00:00
[review] [refactor] Extract lock refresh logic to a load function
This commit is contained in:
@@ -50,25 +50,29 @@ export class LockComponent implements OnInit {
|
|||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
this.stateService.accounts.subscribe(async _accounts => {
|
this.stateService.accounts.subscribe(async _accounts => {
|
||||||
this.pinSet = await this.vaultTimeoutService.isPinLockSet();
|
await this.load();
|
||||||
this.pinLock = (this.pinSet[0] && (await this.stateService.getEncryptedPinProtected()) != null) || this.pinSet[1];
|
|
||||||
this.supportsBiometric = await this.platformUtilsService.supportsBiometric();
|
|
||||||
this.biometricLock = await this.vaultTimeoutService.isBiometricLockSet() &&
|
|
||||||
(await this.cryptoService.hasKeyStored(KeySuffixOptions.Biometric) || !this.platformUtilsService.supportsSecureStorage());
|
|
||||||
this.biometricText = await this.stateService.getBiometricText();
|
|
||||||
this.email = await this.stateService.getEmail();
|
|
||||||
|
|
||||||
// Users with key connector and without biometric or pin has no MP to unlock using
|
|
||||||
if (await this.keyConnectorService.getUsesKeyConnector() && !(this.biometricLock || this.pinLock)) {
|
|
||||||
await this.vaultTimeoutService.logOut();
|
|
||||||
}
|
|
||||||
|
|
||||||
const webVaultUrl = this.environmentService.getWebVaultUrl();
|
|
||||||
const vaultUrl = webVaultUrl === 'https://vault.bitwarden.com' ? 'https://bitwarden.com' : webVaultUrl;
|
|
||||||
this.webVaultHostname = Utils.getHostname(vaultUrl);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async load() {
|
||||||
|
this.pinSet = await this.vaultTimeoutService.isPinLockSet();
|
||||||
|
this.pinLock = (this.pinSet[0] && (await this.stateService.getEncryptedPinProtected()) != null) || this.pinSet[1];
|
||||||
|
this.supportsBiometric = await this.platformUtilsService.supportsBiometric();
|
||||||
|
this.biometricLock = await this.vaultTimeoutService.isBiometricLockSet() &&
|
||||||
|
(await this.cryptoService.hasKeyStored(KeySuffixOptions.Biometric) || !this.platformUtilsService.supportsSecureStorage());
|
||||||
|
this.biometricText = await this.stateService.getBiometricText();
|
||||||
|
this.email = await this.stateService.getEmail();
|
||||||
|
|
||||||
|
// Users with key connector and without biometric or pin has no MP to unlock using
|
||||||
|
if (await this.keyConnectorService.getUsesKeyConnector() && !(this.biometricLock || this.pinLock)) {
|
||||||
|
await this.vaultTimeoutService.logOut();
|
||||||
|
}
|
||||||
|
|
||||||
|
const webVaultUrl = this.environmentService.getWebVaultUrl();
|
||||||
|
const vaultUrl = webVaultUrl === 'https://vault.bitwarden.com' ? 'https://bitwarden.com' : webVaultUrl;
|
||||||
|
this.webVaultHostname = Utils.getHostname(vaultUrl);
|
||||||
|
}
|
||||||
|
|
||||||
async submit() {
|
async submit() {
|
||||||
if (this.pinLock && (this.pin == null || this.pin === '')) {
|
if (this.pinLock && (this.pin == null || this.pin === '')) {
|
||||||
this.platformUtilsService.showToast('error', this.i18nService.t('errorOccurred'),
|
this.platformUtilsService.showToast('error', this.i18nService.t('errorOccurred'),
|
||||||
|
|||||||
Reference in New Issue
Block a user