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

38 lines
1.3 KiB
TypeScript
Raw Normal View History

///<reference path="../../browser.d.ts"/>
2016-05-04 23:20:21 +08:00
import {Component, OnInit} from "@angular/core";
import {AuthenticationService} from "../model/network/authentication.service.ts";
2016-05-04 23:20:21 +08:00
import {Router} from "@angular/router-deprecated";
import {FrameComponent} from "../frame/frame.component";
import {UserRoles} from "../../../common/entities/User";
2016-05-04 23:20:21 +08:00
import {FORM_DIRECTIVES} from "@angular/common";
2016-05-09 23:04:56 +08:00
import {StringifyRole} from "./../pipes/StringifyRolePipe";
2016-07-07 18:26:36 +08:00
import {Config} from "../config/Config";
import {UserMangerSettingsComponent} from "../settings/usermanager/usermanager.settings.component";
@Component({
selector: 'admin',
templateUrl: 'app/admin/admin.component.html',
styleUrls: ['app/admin/admin.component.css'],
directives: [FrameComponent, FORM_DIRECTIVES, UserMangerSettingsComponent],
pipes: [StringifyRole]
})
export class AdminComponent implements OnInit {
2016-07-07 18:26:36 +08:00
userManagementEnable:boolean = false;
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) {
this._router.navigate(['Login']);
return;
}
}
}