|
1 | 1 | import { ChangeDetectionStrategy, Component, Input, OnDestroy, OnInit } from '@angular/core'; |
2 | | - |
3 | | -import { Observable, Subscription } from 'rxjs'; |
4 | | -import { map } from 'rxjs/operators'; |
| 2 | +import { Observable, Subscription, combineLatest } from 'rxjs'; |
| 3 | +import { filter, map, shareReplay } from 'rxjs/operators'; |
5 | 4 | import { select, Store } from '@ngrx/store'; |
6 | 5 | import uniqBy from 'lodash/uniqBy'; |
7 | 6 |
|
@@ -67,6 +66,16 @@ export class LogInComponent implements OnInit, OnDestroy { |
67 | 66 | */ |
68 | 67 | canRegister$: Observable<boolean>; |
69 | 68 |
|
| 69 | + /** |
| 70 | + * Whether or not the current user (or anonymous) is authorized to register an account |
| 71 | + */ |
| 72 | + canForgot$: Observable<boolean>; |
| 73 | + |
| 74 | + /** |
| 75 | + * Shows the divider only if contains at least one link to show |
| 76 | + */ |
| 77 | + canShowDivider$: Observable<boolean>; |
| 78 | + |
70 | 79 | /** |
71 | 80 | * Track subscription to unsubscribe on destroy |
72 | 81 | * @private |
@@ -106,6 +115,14 @@ export class LogInComponent implements OnInit, OnDestroy { |
106 | 115 | }); |
107 | 116 |
|
108 | 117 | this.canRegister$ = this.authorizationService.isAuthorized(FeatureID.EPersonRegistration); |
| 118 | + |
| 119 | + this.canForgot$ = this.authorizationService.isAuthorized(FeatureID.EPersonForgotPassword).pipe(shareReplay(1)); |
| 120 | + this.canShowDivider$ = |
| 121 | + combineLatest([this.canRegister$, this.canForgot$]) |
| 122 | + .pipe( |
| 123 | + map(([canRegister, canForgot]) => canRegister || canForgot), |
| 124 | + filter(Boolean) |
| 125 | + ); |
109 | 126 | } |
110 | 127 |
|
111 | 128 | getRegisterRoute() { |
|
0 commit comments