1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2024-12-14 11:23:17 +02:00
pigallery2/frontend/app/admin/admin.component.ts

29 lines
844 B
TypeScript

import {Component, OnInit} from "@angular/core";
import {AuthenticationService} from "../model/network/authentication.service";
import {Router} from "@angular/router";
import {UserRoles} from "../../../common/entities/UserDTO";
import {Config} from "../../../common/config/public/Config";
@Component({
selector: 'admin',
templateUrl: './admin.component.html',
styleUrls: ['./admin.component.css']
})
export class AdminComponent implements OnInit {
userManagementEnable: boolean = false;
constructor(private _authService: AuthenticationService, private _router: Router) {
this.userManagementEnable = Config.Client.authenticationRequired;
}
ngOnInit() {
if (!this._authService.isAuthenticated() || this._authService.getUser().role < UserRoles.Admin) {
this._router.navigate(['login']);
return;
}
}
}