|
@@ -1,7 +1,8 @@
|
|
| 1 |
import { NgModule } from '@angular/core';
|
| 2 |
-
import { Routes, RouterModule
|
| 3 |
|
| 4 |
import { HomeComponent } from './home/home.component';
|
|
|
|
| 5 |
|
| 6 |
export const routes: Routes = [
|
| 7 |
{
|
|
@@ -15,11 +16,12 @@
|
|
| 15 |
},
|
| 16 |
{
|
| 17 |
path: 'books',
|
| 18 |
-
loadChildren: () => import('src/app/book-monkey/iteration-6/
|
| 19 |
},
|
| 20 |
{
|
| 21 |
path: 'admin',
|
| 22 |
-
loadChildren: () => import('src/app/book-monkey/iteration-6/
|
|
|
|
| 23 |
}
|
| 24 |
];
|
| 25 |
|
| 1 |
import { NgModule } from '@angular/core';
|
| 2 |
+
import { Routes, RouterModule } from '@angular/router';
|
| 3 |
|
| 4 |
import { HomeComponent } from './home/home.component';
|
| 5 |
+
import { CanNavigateToAdminGuard } from './can-navigate-to-admin.guard';
|
| 6 |
|
| 7 |
export const routes: Routes = [
|
| 8 |
{
|
| 16 |
},
|
| 17 |
{
|
| 18 |
path: 'books',
|
| 19 |
+
loadChildren: () => import('src/app/book-monkey/iteration-6/guards/books/books.module').then(m => m.BooksModule)
|
| 20 |
},
|
| 21 |
{
|
| 22 |
path: 'admin',
|
| 23 |
+
loadChildren: () => import('src/app/book-monkey/iteration-6/guards/admin/admin.module').then(m => m.AdminModule),
|
| 24 |
+
canActivate: [CanNavigateToAdminGuard]
|
| 25 |
}
|
| 26 |
];
|
| 27 |
|
|
@@ -16,4 +16,4 @@
|
|
| 16 |
</ng-template>
|
| 17 |
|
| 18 |
</div>
|
| 19 |
-
|
| 16 |
</ng-template>
|
| 17 |
|
| 18 |
</div>
|
| 19 |
+
|
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { Injectable } from '@angular/core';
|
| 2 |
+
import { CanActivate } from '@angular/router';
|
| 3 |
+
|
| 4 |
+
@Injectable({
|
| 5 |
+
providedIn: 'root'
|
| 6 |
+
})
|
| 7 |
+
export class CanNavigateToAdminGuard implements CanActivate {
|
| 8 |
+
|
| 9 |
+
accessGranted = false;
|
| 10 |
+
|
| 11 |
+
canActivate(): boolean {
|
| 12 |
+
if (!this.accessGranted) {
|
| 13 |
+
this.accessGranted = window.confirm('Mit großer Macht kommt große Verantwortung. Möchten Sie den Admin-Bereich betreten?');
|
| 14 |
+
}
|
| 15 |
+
return this.accessGranted;
|
| 16 |
+
}
|
| 17 |
+
}
|