Skip to content

Commit 6040fef

Browse files
committed
Angular Security course
1 parent 9fd6f2c commit 6040fef

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/app.module.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ import {RbacAllowDirective} from "./common/rbac-allow.directive";
2727
import {AuthorizationGuard} from "./services/authorization.guard";
2828

2929

30+
export function createAdminOnlyGuard(authService:AuthService, router:Router) {
31+
return new AuthorizationGuard(['ADMIN'], authService, router);
32+
}
33+
34+
35+
3036
@NgModule({
3137
declarations: [
3238
AppComponent,
@@ -51,9 +57,7 @@ import {AuthorizationGuard} from "./services/authorization.guard";
5157
AuthService,
5258
{
5359
provide: 'adminsOnlyGuard',
54-
useFactory: (authService:AuthService,
55-
router:Router) =>
56-
new AuthorizationGuard(['ADMIN'], authService, router),
60+
useFactory: createAdminOnlyGuard,
5761
deps: [
5862
AuthService,
5963
Router

0 commit comments

Comments
 (0)