1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-08 12:40:26 +00:00

Apply more fixes

This commit is contained in:
Bernd Schoolmann
2025-05-30 14:30:04 +02:00
parent ab5eb30929
commit 8a4feb4b5b
10 changed files with 88 additions and 16 deletions

View File

@@ -8,4 +8,5 @@ export abstract class SyncedUnlockService {
abstract getUserStatusFromDesktop(userId: UserId): Promise<AuthenticationStatus>;
abstract getUserKeyFromDesktop(userId: UserId): Promise<UserKey | null>;
abstract focusDesktopApp(): Promise<void>;
abstract isConnectionTrusted(): Promise<boolean>;
}

View File

@@ -24,4 +24,8 @@ export class NoopSyncedUnlockService extends SyncedUnlockService {
focusDesktopApp(): Promise<void> {
return Promise.resolve();
}
isConnectionTrusted(): Promise<boolean> {
return Promise.resolve(false);
}
}

View File

@@ -16,11 +16,8 @@
</form>
</ng-container>
<ng-container *ngIf="showLocalUnlockOptions">
<bit-hint class="tw-text-center tw-mb-3" *ngIf="unlockViaDesktop && !activeUserLoggedOut">
{{ "lockScreenDesktopNotRunning" | i18n }}
</bit-hint>
<bit-hint class="tw-text-center tw-mb-3" *ngIf="unlockViaDesktop && activeUserLoggedOut">
{{ "lockScreenDesktopRunningButLoggedOut" | i18n }}
<bit-hint class="tw-text-center tw-mb-3" *ngIf="unlockViaDesktop">
{{ synchronizedUnlockUnavailabilityReason }}
</bit-hint>
<!-- Biometrics Unlock -->

View File

@@ -139,8 +139,10 @@ export class LockComponent implements OnInit, OnDestroy {
unlockViaDesktop = false;
isDesktopOpen = false;
isDesktopConnectionTrusted = false;
activeUserLoggedOut = false;
showLocalUnlockOptions = true;
synchronizedUnlockUnavailabilityReason: string = "";
desktopUnlockFormGroup: FormGroup = new FormGroup({});
constructor(
@@ -224,14 +226,41 @@ export class LockComponent implements OnInit, OnDestroy {
}
this.isDesktopOpen = await this.syncedUnlockService.isConnected();
this.isDesktopConnectionTrusted = await this.syncedUnlockService.isConnectionTrusted();
this.activeUserLoggedOut =
(await this.syncedUnlockService.getUserStatusFromDesktop(activeAccount.id)) ===
AuthenticationStatus.LoggedOut;
this.showLocalUnlockOptions = !(
this.isDesktopOpen &&
this.unlockViaDesktop &&
!this.activeUserLoggedOut
);
// Synchronized unlock not enabled
if (!this.unlockViaDesktop) {
this.showLocalUnlockOptions = true;
this.synchronizedUnlockUnavailabilityReason = "";
return;
}
// Synchronized unlock enabled, but cannot be used
if (!this.isDesktopOpen) {
this.showLocalUnlockOptions = true;
this.synchronizedUnlockUnavailabilityReason = this.i18nService.t(
"lockScreenDesktopNotRunning",
);
return;
} else if (this.activeUserLoggedOut) {
this.showLocalUnlockOptions = true;
this.synchronizedUnlockUnavailabilityReason = this.i18nService.t(
"lockScreenDesktopRunningButLoggedOut",
);
return;
} else if (!this.isDesktopConnectionTrusted) {
this.showLocalUnlockOptions = true;
this.synchronizedUnlockUnavailabilityReason = this.i18nService.t(
"lockScreenDesktopRunningButNotTrusted",
);
return;
}
this.showLocalUnlockOptions = false;
this.synchronizedUnlockUnavailabilityReason = "";
} catch (e) {
this.logService.error(e);
}

View File

@@ -6,4 +6,5 @@ export enum SyncedUnlockStateCommands {
GetUserKeyFromDesktop = "getUserKeyFromDesktop",
GetUserStatusFromDesktop = "getUserStatusFromDesktop",
FocusDesktopApp = "focusDesktopApp",
IsConnectionTrusted = "isConnectionTrusted",
}