Skip to content

Commit

Permalink
CST-13251 Removed forgot password
Browse files Browse the repository at this point in the history
  • Loading branch information
Mattia Vianelli committed Jul 17, 2024
1 parent 0a2336a commit f682ed9
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 37 deletions.
11 changes: 8 additions & 3 deletions src/app/shared/log-in/log-in.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
<ds-log-in-container [authMethod]="authMethod" [isStandalonePage]="isStandalonePage"></ds-log-in-container>
<div *ngIf="!last" class="dropdown-divider my-2"></div>
</ng-container>
<div class="dropdown-divider"></div>
<a class="dropdown-item" *ngIf="(canRegister$ | async) && showRegisterLink" [routerLink]="[getRegisterRoute()]" [attr.data-test]="'register' | dsBrowserOnly">{{"login.form.new-user" | translate}}</a>
<a class="dropdown-item" [routerLink]="[getForgotRoute()]" [attr.data-test]="'forgot' | dsBrowserOnly">{{"login.form.forgot-password" | translate}}</a>
<ng-container *ngIf="canShowDivider$ | async">
<div class="mt-2">
<a class="dropdown-item" *ngIf="canRegister$ | async" [routerLink]="[getRegisterRoute()]"
[attr.data-test]="'register' | dsBrowserOnly">{{"login.form.new-user" | translate}}</a>
<a class="dropdown-item" *ngIf="canForgot$ | async" [routerLink]="[getForgotRoute()]"
[attr.data-test]="'forgot' | dsBrowserOnly">{{"login.form.forgot-password" | translate}}</a>
</div>
</ng-container>
</div>
23 changes: 20 additions & 3 deletions src/app/shared/log-in/log-in.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ChangeDetectionStrategy, Component, Input, OnDestroy, OnInit } from '@angular/core';

import { Observable, Subscription } from 'rxjs';
import { map } from 'rxjs/operators';
import { Observable, Subscription, combineLatest } from 'rxjs';
import { filter, map, shareReplay } from 'rxjs/operators';
import { select, Store } from '@ngrx/store';
import uniqBy from 'lodash/uniqBy';

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

/**
* Whether or not the current user (or anonymous) is authorized to register an account
*/
canForgot$: Observable<boolean>;

/**
* Shows the divider only if contains at least one link to show
*/
canShowDivider$: Observable<boolean>;

/**
* Track subscription to unsubscribe on destroy
* @private
Expand Down Expand Up @@ -106,6 +115,14 @@ export class LogInComponent implements OnInit, OnDestroy {
});

this.canRegister$ = this.authorizationService.isAuthorized(FeatureID.EPersonRegistration);

this.canForgot$ = this.authorizationService.isAuthorized(FeatureID.EPersonForgotPassword).pipe(shareReplay(1));
this.canShowDivider$ =
combineLatest([this.canRegister$, this.canForgot$])
.pipe(
map(([canRegister, canForgot]) => canRegister || canForgot),
filter(Boolean)
);
}

getRegisterRoute() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,3 @@
<button class="btn btn-lg btn-primary btn-block mt-3" type="submit" [attr.data-test]="'login-button' | dsBrowserOnly"
[disabled]="!form.valid"><i class="fas fa-sign-in-alt"></i> {{"login.form.submit" | translate}}</button>
</form>

<ng-container *ngIf="canShowDivider$ | async">
<div class="mt-2">
<a class="dropdown-item" *ngIf="canRegister$ | async" [routerLink]="[getRegisterRoute()]"
[attr.data-test]="'register' | dsBrowserOnly">{{"login.form.new-user" | translate}}</a>
<a class="dropdown-item" *ngIf="canForgot$ | async" [routerLink]="[getForgotRoute()]"
[attr.data-test]="'forgot' | dsBrowserOnly">{{"login.form.forgot-password" | translate}}</a>
</div>
</ng-container>
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { combineLatest, Observable, shareReplay } from 'rxjs';
import { filter, map } from 'rxjs/operators';
import { map } from 'rxjs/operators';
import { Component, Inject, OnInit } from '@angular/core';
import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms';

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

import { getAuthenticationError, getAuthenticationInfo, } from '../../../../core/auth/selectors';
Expand All @@ -16,8 +16,8 @@ import { AuthService } from '../../../../core/auth/auth.service';
import { HardRedirectService } from '../../../../core/services/hard-redirect.service';
import { CoreState } from '../../../../core/core-state.model';
import { getForgotPasswordRoute, getRegisterRoute } from '../../../../app-routing-paths';
import { FeatureID } from '../../../../core/data/feature-authorization/feature-id';
import { AuthorizationDataService } from '../../../../core/data/feature-authorization/authorization-data.service';
import { FeatureID } from '../../../../core/data/feature-authorization/feature-id';

/**
* /users/sign-in
Expand Down Expand Up @@ -64,7 +64,7 @@ export class LogInPasswordComponent implements OnInit {

/**
* The authentication form.
* @type {UntypedFormGroup}
* @type {FormGroup}
*/
public form: UntypedFormGroup;

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

/**
* Whether or not the current user (or anonymous) is authorized to register an account
*/
canForgot$: Observable<boolean>;

/**
* Shows the divider only if contains at least one link to show
*/
canShowDivider$: Observable<boolean>;


constructor(
@Inject('authMethodProvider') public injectedAuthMethodModel: AuthMethod,
Expand Down Expand Up @@ -126,14 +116,7 @@ export class LogInPasswordComponent implements OnInit {
})
);

this.canRegister$ = this.authorizationService.isAuthorized(FeatureID.EPersonRegistration).pipe(shareReplay(1));
this.canForgot$ = this.authorizationService.isAuthorized(FeatureID.EPersonForgotPassword).pipe(shareReplay(1));
this.canShowDivider$ =
combineLatest([this.canRegister$, this.canForgot$])
.pipe(
map(([canRegister, canForgot]) => canRegister || canForgot),
filter(Boolean)
);
this.canRegister$ = this.authorizationService.isAuthorized(FeatureID.EPersonRegistration);
}

getRegisterRoute() {
Expand Down

0 comments on commit f682ed9

Please sign in to comment.