11import { ChangeDetectionStrategy , Component , Input , OnDestroy , OnInit } from '@angular/core' ;
22import { filter , map , shareReplay } from 'rxjs/operators' ;
3+ import { combineLatest } from 'rxjs' ;
34import { select , Store } from '@ngrx/store' ;
45import { AuthMethod } from '../../core/auth/models/auth.method' ;
56import {
@@ -98,7 +99,7 @@ export class LogInComponent implements OnInit, OnDestroy {
9899 filter ( routeData => ! ! routeData ) ,
99100 map ( data => data . isBackDoor ) ,
100101 ) ) ,
101- map ( ( [ methods , isBackdoor ] ) => this . filterAndSortAuthMethods ( methods , isBackdoor , environment . auth . disableStandardLogin ) ) ,
102+ map ( ( [ methods , isBackdoor ] ) => this . filterAndSortAuthMethods ( methods , isBackdoor , environment . auth . isPasswordLoginEnabledForAdminsOnly ) ) ,
102103 // ignore the ip authentication method when it's returned by the backend
103104 map ( ( authMethods : AuthMethod [ ] ) => uniqBy ( authMethods . filter ( a => a . authMethodType !== AuthMethodType . Ip ) , 'authMethodType' ) )
104105 ) ;
@@ -118,21 +119,24 @@ export class LogInComponent implements OnInit, OnDestroy {
118119
119120 this . canRegister$ = this . authorizationService . isAuthorized ( FeatureID . EPersonRegistration ) ;
120121
121- this . canForgot$ = this . authorizationService . isAuthorized ( FeatureID . EPersonForgotPassword ) . pipe ( shareReplay ( 1 ) ) ;
122- this . canShowDivider$ = this . canRegister$ . pipe (
123- combineLatestWith ( this . canForgot$ ) ,
124- map ( ( [ canRegister , canForgot ] ) => ( canRegister || canForgot ) && ( ! environment . auth . disableStandardLogin || this . isStandalonePage ) ) ,
125- filter ( Boolean )
122+ this . canForgot$ = this . authorizationService . isAuthorized ( FeatureID . EPersonForgotPassword ) . pipe ( shareReplay ( { refCount : false , bufferSize : 1 } ) ) ;
123+ this . canShowDivider$ = combineLatest ( [
124+ this . canRegister$ ,
125+ this . canForgot$ ,
126+ this . route . data
127+ ] ) . pipe (
128+ map ( ( [ canRegister , canForgot , routeData ] ) => ( canRegister || canForgot ) && ! routeData ?. isBackDoor ) ,
129+ filter ( Boolean ) ,
126130 ) ;
127131 }
128132
129- filterAndSortAuthMethods ( authMethods : AuthMethod [ ] , isBackdoor : boolean , isStandardLoginDisabled = false ) : AuthMethod [ ] {
133+ filterAndSortAuthMethods ( authMethods : AuthMethod [ ] , isBackdoor : boolean , isPasswordLoginEnabledForAdminsOnly = false ) : AuthMethod [ ] {
130134 return authMethods . filter ( ( authMethod : AuthMethod ) => {
131135 const methodComparison = ( authM ) => {
132136 if ( isBackdoor ) {
133137 return authM . authMethodType === AuthMethodType . Password ;
134138 }
135- if ( ! isStandardLoginDisabled ) {
139+ if ( isPasswordLoginEnabledForAdminsOnly ) {
136140 return authM . authMethodType !== AuthMethodType . Password ;
137141 }
138142 return true ;
0 commit comments