--- /dev/null
+import { Injectable } from '@angular/core'
+import {
+ ActivatedRouteSnapshot,
+ CanActivateChild,
+ RouterStateSnapshot,
+ CanActivate
+} from '@angular/router'
+
+import { AuthService } from '../core'
+
+@Injectable()
+export class AdminGuard implements CanActivate, CanActivateChild {
+
+ constructor (private auth: AuthService) {}
+
+ canActivate (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
+ return this.auth.isAdmin()
+ }
+
+ canActivateChild (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
+ return this.canActivate(route, state)
+ }
+}
import { RequestSchedulersRoutes } from './request-schedulers'
import { UsersRoutes } from './users'
import { VideoAbusesRoutes } from './video-abuses'
+import { AdminGuard } from './admin-guard.service'
const adminRoutes: Routes = [
{
path: '',
component: AdminComponent,
- canActivateChild: [ MetaGuard ],
+ canActivate: [ MetaGuard, AdminGuard ],
+ canActivateChild: [ MetaGuard, AdminGuard ],
children: [
{
path: '',
import { UsersComponent, UserAddComponent, UserUpdateComponent, UserListComponent, UserService } from './users'
import { VideoAbusesComponent, VideoAbuseListComponent } from './video-abuses'
import { SharedModule } from '../shared'
+import { AdminGuard } from './admin-guard.service'
@NgModule({
imports: [
providers: [
FriendService,
RequestSchedulersService,
- UserService
+ UserService,
+ AdminGuard
]
})
export class AdminModule { }
<div class="modal-content">
<div class="modal-header">
- <button type="button" class="close" aria-label="Close" (click)="abort()">
+ <button type="button" class="close" aria-label="Close" (click)="cancel()">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title">{{ title }}</h4>