Skip to content

Commit 0e4151e

Browse files
[DSpace#2624][DURACOM-204] Created new guard for forgot route
1 parent 833033d commit 0e4151e

2 files changed

Lines changed: 37 additions & 2 deletions

File tree

src/app/app-routing.module.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { NgModule } from '@angular/core';
2-
import { RouterModule, NoPreloading } from '@angular/router';
2+
import { NoPreloading, RouterModule } from '@angular/router';
33
import { AuthBlockingGuard } from './core/auth/auth-blocking.guard';
44

55
import { AuthenticatedGuard } from './core/auth/authenticated.guard';
@@ -40,6 +40,7 @@ import {
4040
import { ServerCheckGuard } from './core/server-check/server-check.guard';
4141
import { MenuResolver } from './menu.resolver';
4242
import { ThemedPageErrorComponent } from './page-error/themed-page-error.component';
43+
import { ForgotPasswordCheckGuard } from './core/rest-property/forgot-password-check-guard.guard';
4344

4445
@NgModule({
4546
imports: [
@@ -94,7 +95,10 @@ import { ThemedPageErrorComponent } from './page-error/themed-page-error.compone
9495
path: FORGOT_PASSWORD_PATH,
9596
loadChildren: () => import('./forgot-password/forgot-password.module')
9697
.then((m) => m.ForgotPasswordModule),
97-
canActivate: [EndUserAgreementCurrentUserGuard]
98+
canActivate: [
99+
ForgotPasswordCheckGuard,
100+
EndUserAgreementCurrentUserGuard
101+
]
98102
},
99103
{
100104
path: COMMUNITY_MODULE_PATH,
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { Injectable } from '@angular/core';
2+
import { ActivatedRouteSnapshot, Router, RouterStateSnapshot } from '@angular/router';
3+
import { Observable, of } from 'rxjs';
4+
import { AuthorizationDataService } from '../data/feature-authorization/authorization-data.service';
5+
import { FeatureID } from '../data/feature-authorization/feature-id';
6+
import {
7+
SingleFeatureAuthorizationGuard
8+
} from '../data/feature-authorization/feature-authorization-guard/single-feature-authorization.guard';
9+
import { AuthService } from '../auth/auth.service';
10+
11+
@Injectable({
12+
providedIn: 'root'
13+
})
14+
/**
15+
* Guard that checks if the forgot-password feature is enabled
16+
*/
17+
export class ForgotPasswordCheckGuard extends SingleFeatureAuthorizationGuard {
18+
19+
constructor(
20+
protected readonly authorizationService: AuthorizationDataService,
21+
protected readonly router: Router,
22+
protected readonly authService: AuthService
23+
) {
24+
super(authorizationService, router, authService);
25+
}
26+
27+
getFeatureID(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<FeatureID> {
28+
return of(FeatureID.EPersonForgotPassword);
29+
}
30+
31+
}

0 commit comments

Comments
 (0)