]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/services/no-sso-guard.service.ts
import ceph 16.2.6
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / services / no-sso-guard.service.ts
CommitLineData
9f95a23c 1import { Injectable } from '@angular/core';
f67539c2 2import { CanActivate, CanActivateChild } from '@angular/router';
9f95a23c 3
f67539c2 4import { DashboardUserDeniedError } from '~/app/core/error/error';
9f95a23c
TL
5import { 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})
14export 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}