aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/+admin')
-rw-r--r--client/src/app/+admin/admin-guard.service.ts23
-rw-r--r--client/src/app/+admin/admin-routing.module.ts4
-rw-r--r--client/src/app/+admin/admin.module.ts4
3 files changed, 29 insertions, 2 deletions
diff --git a/client/src/app/+admin/admin-guard.service.ts b/client/src/app/+admin/admin-guard.service.ts
new file mode 100644
index 000000000..a0ad48175
--- /dev/null
+++ b/client/src/app/+admin/admin-guard.service.ts
@@ -0,0 +1,23 @@
1import { Injectable } from '@angular/core'
2import {
3 ActivatedRouteSnapshot,
4 CanActivateChild,
5 RouterStateSnapshot,
6 CanActivate
7} from '@angular/router'
8
9import { AuthService } from '../core'
10
11@Injectable()
12export class AdminGuard implements CanActivate, CanActivateChild {
13
14 constructor (private auth: AuthService) {}
15
16 canActivate (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
17 return this.auth.isAdmin()
18 }
19
20 canActivateChild (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
21 return this.canActivate(route, state)
22 }
23}
diff --git a/client/src/app/+admin/admin-routing.module.ts b/client/src/app/+admin/admin-routing.module.ts
index 03782c258..a3845b72c 100644
--- a/client/src/app/+admin/admin-routing.module.ts
+++ b/client/src/app/+admin/admin-routing.module.ts
@@ -8,12 +8,14 @@ import { FriendsRoutes } from './friends'
8import { RequestSchedulersRoutes } from './request-schedulers' 8import { RequestSchedulersRoutes } from './request-schedulers'
9import { UsersRoutes } from './users' 9import { UsersRoutes } from './users'
10import { VideoAbusesRoutes } from './video-abuses' 10import { VideoAbusesRoutes } from './video-abuses'
11import { AdminGuard } from './admin-guard.service'
11 12
12const adminRoutes: Routes = [ 13const adminRoutes: Routes = [
13 { 14 {
14 path: '', 15 path: '',
15 component: AdminComponent, 16 component: AdminComponent,
16 canActivateChild: [ MetaGuard ], 17 canActivate: [ MetaGuard, AdminGuard ],
18 canActivateChild: [ MetaGuard, AdminGuard ],
17 children: [ 19 children: [
18 { 20 {
19 path: '', 21 path: '',
diff --git a/client/src/app/+admin/admin.module.ts b/client/src/app/+admin/admin.module.ts
index 853085a83..786dbc15c 100644
--- a/client/src/app/+admin/admin.module.ts
+++ b/client/src/app/+admin/admin.module.ts
@@ -7,6 +7,7 @@ import { RequestSchedulersComponent, RequestSchedulersStatsComponent, RequestSch
7import { UsersComponent, UserAddComponent, UserUpdateComponent, UserListComponent, UserService } from './users' 7import { UsersComponent, UserAddComponent, UserUpdateComponent, UserListComponent, UserService } from './users'
8import { VideoAbusesComponent, VideoAbuseListComponent } from './video-abuses' 8import { VideoAbusesComponent, VideoAbuseListComponent } from './video-abuses'
9import { SharedModule } from '../shared' 9import { SharedModule } from '../shared'
10import { AdminGuard } from './admin-guard.service'
10 11
11@NgModule({ 12@NgModule({
12 imports: [ 13 imports: [
@@ -40,7 +41,8 @@ import { SharedModule } from '../shared'
40 providers: [ 41 providers: [
41 FriendService, 42 FriendService,
42 RequestSchedulersService, 43 RequestSchedulersService,
43 UserService 44 UserService,
45 AdminGuard
44 ] 46 ]
45}) 47})
46export class AdminModule { } 48export class AdminModule { }