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
67 lines (63 loc) · 2.03 KB
/
app-routing.module.ts
File metadata and controls
67 lines (63 loc) · 2.03 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
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { MsalGuard, 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 { RoleGuard } from './role.guard';
import { roles } 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: [
RoleGuard
],
data: {
expectedRoles: [roles.TaskUser, roles.TaskAdmin]
}
},
{
path: 'todo-view',
component: TodoViewComponent,
canActivate: [
RoleGuard
],
data: {
expectedRoles: [roles.TaskUser, roles.TaskAdmin]
}
},
{
path: 'dashboard',
component: DashboardComponent,
canActivate: [
RoleGuard,
],
data: {
expectedRoles: [roles.TaskAdmin]
}
},
{
// 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 { }