Skip to content

Commit

Permalink
[DURACOM-204][#2622] Makes forgot-password link removable
Browse files Browse the repository at this point in the history
  • Loading branch information
vins01-4science committed Nov 10, 2023
1 parent 684846a commit 91b4d3d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/app/core/data/feature-authorization/feature-id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ export enum FeatureID {
CanEditItem = 'canEditItem',
CanRegisterDOI = 'canRegisterDOI',
CanSubscribe = 'canSubscribeDso',
EPersonForgotPassword = 'epersonForgotPassword',
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
[disabled]="!form.valid"><i class="fas fa-sign-in-alt"></i> {{"login.form.submit" | translate}}</button>
</form>

<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" [routerLink]="[getForgotRoute()]" [attr.data-test]="'forgot' | dsBrowserOnly">
{{ 'login.form.forgot-password' | translate }}
</a>
</div>
<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 { map } from 'rxjs/operators';
import { combineLatest, Observable, shareReplay } from 'rxjs';
import { filter, 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 Down Expand Up @@ -73,6 +73,17 @@ 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,
@Inject('isStandalonePage') public isStandalonePage: boolean,
Expand Down Expand Up @@ -114,8 +125,15 @@ export class LogInPasswordComponent implements OnInit {
return message;
})
);

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

Check failure on line 128 in src/app/shared/log-in/methods/password/log-in-password.component.ts

View workflow job for this annotation

GitHub Actions / tests (16.x)

Trailing spaces not allowed

Check failure on line 128 in src/app/shared/log-in/methods/password/log-in-password.component.ts

View workflow job for this annotation

GitHub Actions / tests (18.x)

Trailing spaces not allowed
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)
);
}

getRegisterRoute() {
Expand Down

0 comments on commit 91b4d3d

Please sign in to comment.