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