1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-10-09 05:57:40 +02:00
bitwarden-browser/src/app/services/organization-guard.service.ts
2018-07-05 15:27:23 -04:00

24 lines
635 B
TypeScript

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;
}
}