1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00
pigallery2/frontend/app/admin/admin.component.ts

29 lines
880 B
TypeScript
Raw Normal View History

2016-05-04 23:20:21 +08:00
import {Component, OnInit} from "@angular/core";
2016-12-27 06:36:38 +08:00
import {AuthenticationService} from "../model/network/authentication.service";
import {Router} from "@angular/router";
2016-12-27 23:09:47 +08:00
import {UserRoles} from "../../../common/entities/UserDTO";
2016-07-07 18:26:36 +08:00
import {Config} from "../config/Config";
@Component({
selector: 'admin',
templateUrl: 'app/admin/admin.component.html',
2016-12-27 06:36:38 +08:00
styleUrls: ['app/admin/admin.component.css']
})
export class AdminComponent implements OnInit {
2016-12-27 06:36:38 +08:00
userManagementEnable: boolean = false;
2016-12-27 06:36:38 +08:00
constructor(private _authService: AuthenticationService, private _router: Router) {
2016-07-07 18:26:36 +08:00
this.userManagementEnable = Config.Client.authenticationRequired;
}
ngOnInit() {
if (!this._authService.isAuthenticated() || this._authService.getUser().role < UserRoles.Admin) {
2016-12-27 23:09:47 +08:00
this._router.navigate(['login']);
return;
}
}
}