mirror of https://github.com/bitwarden/web.git
6 changed files with 80 additions and 22 deletions
@ -1 +1 @@
@@ -1 +1 @@
|
||||
Subproject commit 87e273252be42dab90d9a33857fe7755f378338b |
||||
Subproject commit 91081d92327da22ab3be88a60f8b71be26933370 |
||||
@ -0,0 +1,23 @@
@@ -0,0 +1,23 @@
|
||||
import { Injectable } from '@angular/core'; |
||||
import { |
||||
ActivatedRouteSnapshot, |
||||
CanActivate, |
||||
Router, |
||||
} from '@angular/router'; |
||||
|
||||
import { UserService } from 'jslib/abstractions/user.service'; |
||||
|
||||
@Injectable() |
||||
export class OrganizationGuardService implements CanActivate { |
||||
constructor(private userService: UserService, private router: Router) { } |
||||
|
||||
async canActivate(route: ActivatedRouteSnapshot) { |
||||
const org = await this.userService.getOrganization(route.params.organizationId); |
||||
if (org == null) { |
||||
this.router.navigate(['/']); |
||||
return false; |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
} |
||||
@ -0,0 +1,26 @@
@@ -0,0 +1,26 @@
|
||||
import { Injectable } from '@angular/core'; |
||||
import { |
||||
ActivatedRouteSnapshot, |
||||
CanActivate, |
||||
Router, |
||||
} from '@angular/router'; |
||||
|
||||
import { UserService } from 'jslib/abstractions/user.service'; |
||||
|
||||
import { OrganizationUserType } from 'jslib/enums/organizationUserType'; |
||||
|
||||
@Injectable() |
||||
export class OrganizationTypeGuardService implements CanActivate { |
||||
constructor(private userService: UserService, private router: Router) { } |
||||
|
||||
async canActivate(route: ActivatedRouteSnapshot) { |
||||
const org = await this.userService.getOrganization(route.parent.params.organizationId); |
||||
const allowedTypes = route.data['allowedTypes'] as OrganizationUserType[]; |
||||
if (allowedTypes == null || allowedTypes.indexOf(org.type) === -1) { |
||||
this.router.navigate(['/organizations', org.id]); |
||||
return false; |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
} |
||||
Loading…
Reference in new issue