mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 17:53:39 +00:00
* Initial work on windows hello support * Switch to use windows.security.credentials.ui UserConsentVerifier * Fix linting warnings * Remove unessesary supportsBiometric from lock screen * Rename biometric.main to windows.biometric.main. Add abstraction for biometric. * Add support for dynamic biometric text. * Add untested darwin implementation * Rename fingerprintUnlock to biometric * Add new functions to cliPlatformUtils.service.ts. * Hide login if biometric is not supported * Export default for biometric.*.main.ts * Remove @nodert-win10-rs4/windows.security.credentials * Add build requirements to readme * Auto prompt biometric when starting the application. * Ensure we support biometric before trying to auto prompt. * Fix review comments and linting errors
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import { Injectable } from '@angular/core';
|
|
import {
|
|
ActivatedRouteSnapshot,
|
|
CanActivate,
|
|
Router,
|
|
RouterStateSnapshot,
|
|
} from '@angular/router';
|
|
|
|
import { MessagingService } from '../../abstractions/messaging.service';
|
|
import { UserService } from '../../abstractions/user.service';
|
|
import { VaultTimeoutService } from '../../abstractions/vaultTimeout.service';
|
|
|
|
@Injectable()
|
|
export class AuthGuardService implements CanActivate {
|
|
constructor(private vaultTimeoutService: VaultTimeoutService, private userService: UserService,
|
|
private router: Router, private messagingService: MessagingService) { }
|
|
|
|
async canActivate(route: ActivatedRouteSnapshot, routerState: RouterStateSnapshot) {
|
|
const isAuthed = await this.userService.isAuthenticated();
|
|
if (!isAuthed) {
|
|
this.messagingService.send('authBlocked');
|
|
return false;
|
|
}
|
|
|
|
const locked = await this.vaultTimeoutService.isLocked();
|
|
if (locked) {
|
|
if (routerState != null) {
|
|
this.messagingService.send('lockedUrl', { url: routerState.url });
|
|
}
|
|
this.router.navigate(['lock'], { queryParams: { promptBiometric: true }});
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|