1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-21 10:43:35 +00:00

Route to vault page when user doesn't have access (#14633)

This commit is contained in:
SmithThe4th
2025-05-13 11:21:07 -04:00
committed by GitHub
parent 9a7089594e
commit 0750ff38f5
2 changed files with 11 additions and 4 deletions

View File

@@ -5321,5 +5321,8 @@
"message": "Learn more about SSH agent", "message": "Learn more about SSH agent",
"description": "Two part message", "description": "Two part message",
"example": "Store your keys and connect with the SSH agent for fast, encrypted authentication. Learn more about SSH agent" "example": "Store your keys and connect with the SSH agent for fast, encrypted authentication. Learn more about SSH agent"
},
"noPermissionsViewPage": {
"message": "You do not have permissions to view this page. Try logging in with a different account."
} }
} }

View File

@@ -1,6 +1,6 @@
import { inject } from "@angular/core"; import { inject } from "@angular/core";
import { CanActivateFn } from "@angular/router"; import { CanActivateFn, Router } from "@angular/router";
import { switchMap, tap } from "rxjs"; import { map, switchMap } from "rxjs";
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
@@ -13,18 +13,22 @@ export const canAccessAtRiskPasswords: CanActivateFn = () => {
const taskService = inject(TaskService); const taskService = inject(TaskService);
const toastService = inject(ToastService); const toastService = inject(ToastService);
const i18nService = inject(I18nService); const i18nService = inject(I18nService);
const router = inject(Router);
return accountService.activeAccount$.pipe( return accountService.activeAccount$.pipe(
filterOutNullish(), filterOutNullish(),
switchMap((user) => taskService.tasksEnabled$(user.id)), switchMap((user) => taskService.tasksEnabled$(user.id)),
tap((tasksEnabled) => { map((tasksEnabled) => {
if (!tasksEnabled) { if (!tasksEnabled) {
toastService.showToast({ toastService.showToast({
variant: "error", variant: "error",
title: "", title: "",
message: i18nService.t("accessDenied"), message: i18nService.t("noPermissionsViewPage"),
}); });
return router.createUrlTree(["/tabs/vault"]);
} }
return true;
}), }),
); );
}; };