]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/services/no-sso-guard.service.ts
import 15.2.0 Octopus source
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / services / no-sso-guard.service.ts
1 import { Injectable } from '@angular/core';
2 import { CanActivate, CanActivateChild, Router } from '@angular/router';
3
4 import { AuthStorageService } from './auth-storage.service';
5
6 /**
7 * This service checks if a route can be activated if the user has not
8 * been logged in via SSO.
9 */
10 @Injectable({
11 providedIn: 'root'
12 })
13 export class NoSsoGuardService implements CanActivate, CanActivateChild {
14 constructor(private authStorageService: AuthStorageService, private router: Router) {}
15
16 canActivate() {
17 if (!this.authStorageService.isSSO()) {
18 return true;
19 }
20 this.router.navigate(['404']);
21 return false;
22 }
23
24 canActivateChild(): boolean {
25 return this.canActivate();
26 }
27 }