mirror of
https://github.com/bitwarden/web
synced 2026-01-19 00:43:54 +00:00
Merge remote-tracking branch 'origin/master' into feature/endUserVaultRefresh
This commit is contained in:
@@ -5,6 +5,7 @@ import { BaseGuard } from "jslib-angular/guards/base.guard";
|
||||
import { I18nService } from "jslib-common/abstractions/i18n.service";
|
||||
import { OrganizationService } from "jslib-common/abstractions/organization.service";
|
||||
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
|
||||
import { SyncService } from "jslib-common/abstractions/sync.service";
|
||||
import { Permissions } from "jslib-common/enums/permissions";
|
||||
|
||||
@Injectable()
|
||||
@@ -13,15 +14,21 @@ export class PermissionsGuard extends BaseGuard implements CanActivate {
|
||||
router: Router,
|
||||
private organizationService: OrganizationService,
|
||||
private platformUtilsService: PlatformUtilsService,
|
||||
private i18nService: I18nService
|
||||
private i18nService: I18nService,
|
||||
private syncService: SyncService
|
||||
) {
|
||||
super(router);
|
||||
}
|
||||
|
||||
async canActivate(route: ActivatedRouteSnapshot) {
|
||||
// TODO: We need to fix this issue once and for all.
|
||||
if ((await this.syncService.getLastSync()) == null) {
|
||||
await this.syncService.fullSync(false);
|
||||
}
|
||||
|
||||
const org = await this.organizationService.get(route.params.organizationId);
|
||||
if (org == null) {
|
||||
return this.redirect();
|
||||
return this.router.createUrlTree(["/"]);
|
||||
}
|
||||
|
||||
if (!org.isOwner && !org.enabled) {
|
||||
@@ -30,13 +37,13 @@ export class PermissionsGuard extends BaseGuard implements CanActivate {
|
||||
null,
|
||||
this.i18nService.t("organizationIsDisabled")
|
||||
);
|
||||
return this.redirect();
|
||||
return this.router.createUrlTree(["/"]);
|
||||
}
|
||||
|
||||
const permissions = route.data == null ? [] : (route.data.permissions as Permissions[]);
|
||||
if (permissions != null && !org.hasAnyPermission(permissions)) {
|
||||
this.platformUtilsService.showToast("error", null, this.i18nService.t("accessDenied"));
|
||||
return this.redirect();
|
||||
return this.router.createUrlTree(["/"]);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user