This repository was archived by the owner on May 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 174
Expand file tree
/
Copy pathapp-routing.module.ts
More file actions
76 lines (72 loc) · 2.27 KB
/
app-routing.module.ts
File metadata and controls
76 lines (72 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { MsalRedirectComponent } from '@azure/msal-angular';
import { BrowserUtils } from '@azure/msal-browser';
import { HomeComponent } from './home/home.component';
import { TodoViewComponent } from './todo-view/todo-view.component';
import { TodoEditComponent } from './todo-edit/todo-edit.component';
import { DashboardComponent } from './dashboard/dashboard.component';
import { OverageComponent } from './overage/overage.component';
import { BaseGuard } from './base.guard';
import { GroupGuard } from './group.guard';
import { groups } from './auth-config';
/**
* MSAL Angular can protect routes in your application using MsalGuard. For more info, visit:
* https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-angular/docs/v2-docs/initialization.md#secure-the-routes-in-your-application
*/
const routes: Routes = [
{
path: 'todo-edit/:id',
component: TodoEditComponent,
canActivate: [
GroupGuard
],
data: {
requiredGroups: [groups.groupMember, groups.groupAdmin]
}
},
{
path: 'todo-view',
component: TodoViewComponent,
canActivate: [
GroupGuard
],
data: {
requiredGroups: [groups.groupMember, groups.groupAdmin]
}
},
{
path: 'dashboard',
component: DashboardComponent,
canActivate: [
GroupGuard,
],
data: {
requiredGroups: [groups.groupAdmin]
}
},
{
path: 'overage',
component: OverageComponent,
canActivate: [
BaseGuard,
]
},
{
// Needed for handling redirect after login
path: 'auth',
component: MsalRedirectComponent
},
{
path: '',
component: HomeComponent
}
];
@NgModule({
imports: [RouterModule.forRoot(routes, {
// Don't perform initial navigation in iframes or popups
initialNavigation: !BrowserUtils.isInIframe() && !BrowserUtils.isInPopup() ? 'enabledNonBlocking' : 'disabled' // Set to enabledBlocking to use Angular Universal
})],
exports: [RouterModule]
})
export class AppRoutingModule { }