Skip to content

Commit f682ed9

Browse files
author
Mattia Vianelli
committed
CST-13251 Removed forgot password
1 parent 0a2336a commit f682ed9

4 files changed

Lines changed: 33 additions & 37 deletions

File tree

src/app/shared/log-in/log-in.component.html

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
<ds-log-in-container [authMethod]="authMethod" [isStandalonePage]="isStandalonePage"></ds-log-in-container>
55
<div *ngIf="!last" class="dropdown-divider my-2"></div>
66
</ng-container>
7-
<div class="dropdown-divider"></div>
8-
<a class="dropdown-item" *ngIf="(canRegister$ | async) && showRegisterLink" [routerLink]="[getRegisterRoute()]" [attr.data-test]="'register' | dsBrowserOnly">{{"login.form.new-user" | translate}}</a>
9-
<a class="dropdown-item" [routerLink]="[getForgotRoute()]" [attr.data-test]="'forgot' | dsBrowserOnly">{{"login.form.forgot-password" | translate}}</a>
7+
<ng-container *ngIf="canShowDivider$ | async">
8+
<div class="mt-2">
9+
<a class="dropdown-item" *ngIf="canRegister$ | async" [routerLink]="[getRegisterRoute()]"
10+
[attr.data-test]="'register' | dsBrowserOnly">{{"login.form.new-user" | translate}}</a>
11+
<a class="dropdown-item" *ngIf="canForgot$ | async" [routerLink]="[getForgotRoute()]"
12+
[attr.data-test]="'forgot' | dsBrowserOnly">{{"login.form.forgot-password" | translate}}</a>
13+
</div>
14+
</ng-container>
1015
</div>

src/app/shared/log-in/log-in.component.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
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';
54
import { select, Store } from '@ngrx/store';
65
import uniqBy from 'lodash/uniqBy';
76

@@ -67,6 +66,16 @@ export class LogInComponent implements OnInit, OnDestroy {
6766
*/
6867
canRegister$: Observable<boolean>;
6968

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+
7079
/**
7180
* Track subscription to unsubscribe on destroy
7281
* @private
@@ -106,6 +115,14 @@ export class LogInComponent implements OnInit, OnDestroy {
106115
});
107116

108117
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+
);
109126
}
110127

111128
getRegisterRoute() {

src/app/shared/log-in/methods/password/log-in-password.component.html

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,3 @@
2828
<button class="btn btn-lg btn-primary btn-block mt-3" type="submit" [attr.data-test]="'login-button' | dsBrowserOnly"
2929
[disabled]="!form.valid"><i class="fas fa-sign-in-alt"></i> {{"login.form.submit" | translate}}</button>
3030
</form>
31-
32-
<ng-container *ngIf="canShowDivider$ | async">
33-
<div class="mt-2">
34-
<a class="dropdown-item" *ngIf="canRegister$ | async" [routerLink]="[getRegisterRoute()]"
35-
[attr.data-test]="'register' | dsBrowserOnly">{{"login.form.new-user" | translate}}</a>
36-
<a class="dropdown-item" *ngIf="canForgot$ | async" [routerLink]="[getForgotRoute()]"
37-
[attr.data-test]="'forgot' | dsBrowserOnly">{{"login.form.forgot-password" | translate}}</a>
38-
</div>
39-
</ng-container>

src/app/shared/log-in/methods/password/log-in-password.component.ts

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { combineLatest, Observable, shareReplay } from 'rxjs';
2-
import { filter, map } from 'rxjs/operators';
1+
import { map } from 'rxjs/operators';
32
import { Component, Inject, OnInit } from '@angular/core';
43
import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms';
54

65
import { select, Store } from '@ngrx/store';
6+
import { Observable } from 'rxjs';
77
import { AuthenticateAction, ResetAuthenticationMessagesAction } from '../../../../core/auth/auth.actions';
88

99
import { getAuthenticationError, getAuthenticationInfo, } from '../../../../core/auth/selectors';
@@ -16,8 +16,8 @@ import { AuthService } from '../../../../core/auth/auth.service';
1616
import { HardRedirectService } from '../../../../core/services/hard-redirect.service';
1717
import { CoreState } from '../../../../core/core-state.model';
1818
import { getForgotPasswordRoute, getRegisterRoute } from '../../../../app-routing-paths';
19-
import { FeatureID } from '../../../../core/data/feature-authorization/feature-id';
2019
import { AuthorizationDataService } from '../../../../core/data/feature-authorization/authorization-data.service';
20+
import { FeatureID } from '../../../../core/data/feature-authorization/feature-id';
2121

2222
/**
2323
* /users/sign-in
@@ -64,7 +64,7 @@ export class LogInPasswordComponent implements OnInit {
6464

6565
/**
6666
* The authentication form.
67-
* @type {UntypedFormGroup}
67+
* @type {FormGroup}
6868
*/
6969
public form: UntypedFormGroup;
7070

@@ -73,16 +73,6 @@ export class LogInPasswordComponent implements OnInit {
7373
*/
7474
public canRegister$: Observable<boolean>;
7575

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-
8676

8777
constructor(
8878
@Inject('authMethodProvider') public injectedAuthMethodModel: AuthMethod,
@@ -126,14 +116,7 @@ export class LogInPasswordComponent implements OnInit {
126116
})
127117
);
128118

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+
this.canRegister$ = this.authorizationService.isAuthorized(FeatureID.EPersonRegistration);
137120
}
138121

139122
getRegisterRoute() {

0 commit comments

Comments
 (0)