aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-09-10 09:24:50 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-09-10 09:24:50 +0200
commit7ca86c864e102b65e4ff3224a06554a66148fef8 (patch)
tree8554b9069257d94cf567981140a0881b566d8b3d /client/src/app
parent6599f096d5a26f2cc9624359d92cc501ec189586 (diff)
downloadPeerTube-7ca86c864e102b65e4ff3224a06554a66148fef8.tar.gz
PeerTube-7ca86c864e102b65e4ff3224a06554a66148fef8.tar.zst
PeerTube-7ca86c864e102b65e4ff3224a06554a66148fef8.zip
Client: add guard to admin routes
Diffstat (limited to 'client/src/app')
-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
-rw-r--r--client/src/app/core/confirm/confirm.component.html2
4 files changed, 30 insertions, 3 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 { }
diff --git a/client/src/app/core/confirm/confirm.component.html b/client/src/app/core/confirm/confirm.component.html
index 8e5443c6a..2726af6cc 100644
--- a/client/src/app/core/confirm/confirm.component.html
+++ b/client/src/app/core/confirm/confirm.component.html
@@ -3,7 +3,7 @@
3 <div class="modal-content"> 3 <div class="modal-content">
4 4
5 <div class="modal-header"> 5 <div class="modal-header">
6 <button type="button" class="close" aria-label="Close" (click)="abort()"> 6 <button type="button" class="close" aria-label="Close" (click)="cancel()">
7 <span aria-hidden="true">&times;</span> 7 <span aria-hidden="true">&times;</span>
8 </button> 8 </button>
9 <h4 class="modal-title">{{ title }}</h4> 9 <h4 class="modal-title">{{ title }}</h4>