Skip to content

Commit 0750ff3

Browse files
authored
Route to vault page when user doesn't have access (#14633)
1 parent 9a70895 commit 0750ff3

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

apps/browser/src/_locales/en/messages.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5321,5 +5321,8 @@
53215321
"message": "Learn more about SSH agent",
53225322
"description": "Two part message",
53235323
"example": "Store your keys and connect with the SSH agent for fast, encrypted authentication. Learn more about SSH agent"
5324+
},
5325+
"noPermissionsViewPage": {
5326+
"message": "You do not have permissions to view this page. Try logging in with a different account."
53245327
}
53255328
}

apps/browser/src/vault/guards/at-risk-passwords.guard.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { inject } from "@angular/core";
2-
import { CanActivateFn } from "@angular/router";
3-
import { switchMap, tap } from "rxjs";
2+
import { CanActivateFn, Router } from "@angular/router";
3+
import { map, switchMap } from "rxjs";
44

55
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
66
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
@@ -13,18 +13,22 @@ export const canAccessAtRiskPasswords: CanActivateFn = () => {
1313
const taskService = inject(TaskService);
1414
const toastService = inject(ToastService);
1515
const i18nService = inject(I18nService);
16+
const router = inject(Router);
1617

1718
return accountService.activeAccount$.pipe(
1819
filterOutNullish(),
1920
switchMap((user) => taskService.tasksEnabled$(user.id)),
20-
tap((tasksEnabled) => {
21+
map((tasksEnabled) => {
2122
if (!tasksEnabled) {
2223
toastService.showToast({
2324
variant: "error",
2425
title: "",
25-
message: i18nService.t("accessDenied"),
26+
message: i18nService.t("noPermissionsViewPage"),
2627
});
28+
29+
return router.createUrlTree(["/tabs/vault"]);
2730
}
31+
return true;
2832
}),
2933
);
3034
};

0 commit comments

Comments
 (0)