From 7b55c8ad1a330dde3dd0d356f106d61e6969cd03 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Tue, 17 May 2022 18:46:42 +0200 Subject: [PATCH] [EC-203] Add logic for falling back to the users vault (#1688) * Add logic for falling back to the users vault * Update error message * Add jira ticket --- src/app/organizations/guards/permissions.guard.ts | 14 ++++++++++++-- src/locales/en/messages.json | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/app/organizations/guards/permissions.guard.ts b/src/app/organizations/guards/permissions.guard.ts index 4ad57895fd..2f20355920 100644 --- a/src/app/organizations/guards/permissions.guard.ts +++ b/src/app/organizations/guards/permissions.guard.ts @@ -1,5 +1,5 @@ import { Injectable } from "@angular/core"; -import { ActivatedRouteSnapshot, CanActivate, Router } from "@angular/router"; +import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot } from "@angular/router"; import { I18nService } from "jslib-common/abstractions/i18n.service"; import { OrganizationService } from "jslib-common/abstractions/organization.service"; @@ -17,7 +17,7 @@ export class PermissionsGuard implements CanActivate { private syncService: SyncService ) {} - async canActivate(route: ActivatedRouteSnapshot) { + async canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { // TODO: We need to fix this issue once and for all. if ((await this.syncService.getLastSync()) == null) { await this.syncService.fullSync(false); @@ -39,6 +39,16 @@ export class PermissionsGuard implements CanActivate { const permissions = route.data == null ? [] : (route.data.permissions as Permissions[]); if (permissions != null && !org.hasAnyPermission(permissions)) { + // Handle linkable ciphers for organizations the user only has view access to + // https://bitwarden.atlassian.net/browse/EC-203 + if (state.root.queryParamMap.has("cipherId")) { + return this.router.createUrlTree(["/vault"], { + queryParams: { + cipherId: state.root.queryParamMap.get("cipherId"), + }, + }); + } + this.platformUtilsService.showToast("error", null, this.i18nService.t("accessDenied")); return this.router.createUrlTree(["/"]); } diff --git a/src/locales/en/messages.json b/src/locales/en/messages.json index 26cc24d0ea..4e15b6ad05 100644 --- a/src/locales/en/messages.json +++ b/src/locales/en/messages.json @@ -5005,7 +5005,7 @@ "message": "Service" }, "unknownCipher": { - "message": "Unknown Item, you may need to login with another account to access this item." + "message": "Unknown Item, you may need to request permission to access this item." }, "cannotSponsorSelf": { "message": "You cannot redeem for the active account. Enter a different email."