diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 70c4c8edd7f..d329d97ed19 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -43,6 +43,7 @@ import { import { ServerCheckGuard } from './core/server-check/server-check.guard'; import { MenuResolver } from './menu.resolver'; import { ThemedPageErrorComponent } from './page-error/themed-page-error.component'; +import { ForgotPasswordCheckGuard } from './core/rest-property/forgot-password-check-guard.guard'; import { SUGGESTION_MODULE_PATH } from './suggestions-page/suggestions-page-routing-paths'; import { RedirectService } from './redirect/redirect.service'; @@ -99,7 +100,10 @@ import { RedirectService } from './redirect/redirect.service'; path: FORGOT_PASSWORD_PATH, loadChildren: () => import('./forgot-password/forgot-password.module') .then((m) => m.ForgotPasswordModule), - canActivate: [EndUserAgreementCurrentUserGuard] + canActivate: [ + ForgotPasswordCheckGuard, + EndUserAgreementCurrentUserGuard + ] }, { path: COMMUNITY_MODULE_PATH, diff --git a/src/app/core/rest-property/forgot-password-check-guard.guard.ts b/src/app/core/rest-property/forgot-password-check-guard.guard.ts new file mode 100644 index 00000000000..438a532c7b9 --- /dev/null +++ b/src/app/core/rest-property/forgot-password-check-guard.guard.ts @@ -0,0 +1,31 @@ +import { Injectable } from '@angular/core'; +import { ActivatedRouteSnapshot, Router, RouterStateSnapshot } from '@angular/router'; +import { Observable, of } from 'rxjs'; +import { AuthorizationDataService } from '../data/feature-authorization/authorization-data.service'; +import { FeatureID } from '../data/feature-authorization/feature-id'; +import { + SingleFeatureAuthorizationGuard +} from '../data/feature-authorization/feature-authorization-guard/single-feature-authorization.guard'; +import { AuthService } from '../auth/auth.service'; + +@Injectable({ + providedIn: 'root' +}) +/** + * Guard that checks if the forgot-password feature is enabled + */ +export class ForgotPasswordCheckGuard extends SingleFeatureAuthorizationGuard { + + constructor( + protected readonly authorizationService: AuthorizationDataService, + protected readonly router: Router, + protected readonly authService: AuthService + ) { + super(authorizationService, router, authService); + } + + getFeatureID(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable { + return of(FeatureID.EPersonForgotPassword); + } + +}