|
1 | | -import { map } from 'rxjs/operators'; |
| 1 | +import { combineLatest, Observable, shareReplay } from 'rxjs'; |
| 2 | +import { filter, map } from 'rxjs/operators'; |
2 | 3 | import { Component, Inject, OnInit } from '@angular/core'; |
3 | 4 | import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms'; |
4 | 5 |
|
5 | 6 | import { select, Store } from '@ngrx/store'; |
6 | | -import { Observable } from 'rxjs'; |
7 | 7 | import { AuthenticateAction, ResetAuthenticationMessagesAction } from '../../../../core/auth/auth.actions'; |
8 | 8 |
|
9 | 9 | import { getAuthenticationError, getAuthenticationInfo, } from '../../../../core/auth/selectors'; |
@@ -73,6 +73,17 @@ export class LogInPasswordComponent implements OnInit { |
73 | 73 | */ |
74 | 74 | public canRegister$: Observable<boolean>; |
75 | 75 |
|
| 76 | + /** |
| 77 | + * Whether or not the current user (or anonymous) is authorized to register an account |
| 78 | + */ |
| 79 | + canForgot$: Observable<boolean>; |
| 80 | + |
| 81 | + /** |
| 82 | + * Shows the divider only if contains at least one link to show |
| 83 | + */ |
| 84 | + canShowDivider$: Observable<boolean>; |
| 85 | + |
| 86 | + |
76 | 87 | constructor( |
77 | 88 | @Inject('authMethodProvider') public injectedAuthMethodModel: AuthMethod, |
78 | 89 | @Inject('isStandalonePage') public isStandalonePage: boolean, |
@@ -114,8 +125,15 @@ export class LogInPasswordComponent implements OnInit { |
114 | 125 | return message; |
115 | 126 | }) |
116 | 127 | ); |
117 | | - |
118 | | - this.canRegister$ = this.authorizationService.isAuthorized(FeatureID.EPersonRegistration); |
| 128 | + |
| 129 | + this.canRegister$ = this.authorizationService.isAuthorized(FeatureID.EPersonRegistration).pipe(shareReplay(1)); |
| 130 | + this.canForgot$ = this.authorizationService.isAuthorized(FeatureID.EPersonForgotPassword).pipe(shareReplay(1)); |
| 131 | + this.canShowDivider$ = |
| 132 | + combineLatest([this.canRegister$, this.canForgot$]) |
| 133 | + .pipe( |
| 134 | + map(([canRegister, canForgot]) => canRegister || canForgot), |
| 135 | + filter(Boolean) |
| 136 | + ); |
119 | 137 | } |
120 | 138 |
|
121 | 139 | getRegisterRoute() { |
|
0 commit comments