Skip to content

Commit 0a2336a

Browse files
vins01-4scienceMattia Vianelli
authored andcommitted
[DSpace#2624][DURACOM-204] Created new guard for forgot route
(cherry picked from commit 0e4151e)
1 parent c03edee commit 0a2336a

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

src/app/app-routing.module.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import {
4343
import { ServerCheckGuard } from './core/server-check/server-check.guard';
4444
import { MenuResolver } from './menu.resolver';
4545
import { ThemedPageErrorComponent } from './page-error/themed-page-error.component';
46+
import { ForgotPasswordCheckGuard } from './core/rest-property/forgot-password-check-guard.guard';
4647
import { SUGGESTION_MODULE_PATH } from './suggestions-page/suggestions-page-routing-paths';
4748
import { RedirectService } from './redirect/redirect.service';
4849

@@ -99,7 +100,10 @@ import { RedirectService } from './redirect/redirect.service';
99100
path: FORGOT_PASSWORD_PATH,
100101
loadChildren: () => import('./forgot-password/forgot-password.module')
101102
.then((m) => m.ForgotPasswordModule),
102-
canActivate: [EndUserAgreementCurrentUserGuard]
103+
canActivate: [
104+
ForgotPasswordCheckGuard,
105+
EndUserAgreementCurrentUserGuard
106+
]
103107
},
104108
{
105109
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)