]>
Commit | Line | Data |
---|---|---|
9f95a23c | 1 | import { Injectable } from '@angular/core'; |
f67539c2 | 2 | import { CanActivate, CanActivateChild } from '@angular/router'; |
9f95a23c | 3 | |
f67539c2 | 4 | import { DashboardUserDeniedError } from '~/app/core/error/error'; |
9f95a23c TL |
5 | import { AuthStorageService } from './auth-storage.service'; |
6 | ||
7 | /** | |
8 | * This service checks if a route can be activated if the user has not | |
9 | * been logged in via SSO. | |
10 | */ | |
11 | @Injectable({ | |
12 | providedIn: 'root' | |
13 | }) | |
14 | export class NoSsoGuardService implements CanActivate, CanActivateChild { | |
f67539c2 | 15 | constructor(private authStorageService: AuthStorageService) {} |
9f95a23c TL |
16 | |
17 | canActivate() { | |
18 | if (!this.authStorageService.isSSO()) { | |
19 | return true; | |
20 | } | |
f67539c2 | 21 | throw new DashboardUserDeniedError(); |
9f95a23c TL |
22 | return false; |
23 | } | |
24 | ||
25 | canActivateChild(): boolean { | |
26 | return this.canActivate(); | |
27 | } | |
28 | } |