-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename newDeviceVerificationGuard to activeAuthGuard
- Loading branch information
1 parent
a87d2b6
commit 09a4441
Showing
6 changed files
with
36 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { inject } from "@angular/core"; | ||
import { CanActivateFn, Router } from "@angular/router"; | ||
import { firstValueFrom } from "rxjs"; | ||
|
||
import { LoginStrategyServiceAbstraction } from "@bitwarden/auth/common"; | ||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service"; | ||
|
||
/** | ||
* Guard that ensures there is an active login session before allowing access | ||
* to the new device verification route. | ||
* If not, redirects to login. | ||
*/ | ||
export function activeAuthGuard(): CanActivateFn { | ||
return async () => { | ||
const loginStrategyService = inject(LoginStrategyServiceAbstraction); | ||
const logService = inject(LogService); | ||
const router = inject(Router); | ||
|
||
// Check if we have a valid login session | ||
const authType = await firstValueFrom(loginStrategyService.currentAuthType$); | ||
if (authType === null) { | ||
logService.error("No active login session found."); | ||
return router.createUrlTree(["/login"]); | ||
} | ||
|
||
return true; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
export * from "./auth.guard"; | ||
export * from "./active-auth.guard"; | ||
export * from "./lock.guard"; | ||
export * from "./redirect.guard"; | ||
export * from "./tde-decryption-required.guard"; | ||
export * from "./unauth.guard"; | ||
export * from "./new-device-verification.guard"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters