mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 02:24:11 +00:00
Merge pull request #2575 from tdonohue/port_2530_to_7x
[Port to dspace-7_x] Fix display LogInComponent turning blank when entering wrong username/password combination
This commit is contained in:
@@ -74,7 +74,7 @@ export class AuthorizationDataService extends BaseDataService<Authorization> imp
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
catchError(() => observableOf(false)),
|
catchError(() => observableOf([])),
|
||||||
oneAuthorizationMatchesFeature(featureId)
|
oneAuthorizationMatchesFeature(featureId)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -68,13 +68,13 @@ export const oneAuthorizationMatchesFeature = (featureID: FeatureID) =>
|
|||||||
source.pipe(
|
source.pipe(
|
||||||
switchMap((authorizations: Authorization[]) => {
|
switchMap((authorizations: Authorization[]) => {
|
||||||
if (isNotEmpty(authorizations)) {
|
if (isNotEmpty(authorizations)) {
|
||||||
return observableCombineLatest(
|
return observableCombineLatest([
|
||||||
...authorizations
|
...authorizations
|
||||||
.filter((authorization: Authorization) => hasValue(authorization.feature))
|
.filter((authorization: Authorization) => hasValue(authorization.feature))
|
||||||
.map((authorization: Authorization) => authorization.feature.pipe(
|
.map((authorization: Authorization) => authorization.feature.pipe(
|
||||||
getFirstSucceededRemoteDataPayload()
|
getFirstSucceededRemoteDataPayload()
|
||||||
))
|
))
|
||||||
);
|
]);
|
||||||
} else {
|
} else {
|
||||||
return observableOf([]);
|
return observableOf([]);
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
import { Component, Injector, Input, OnInit } from '@angular/core';
|
import { Component, Injector, Input, OnInit, Type } from '@angular/core';
|
||||||
|
|
||||||
import { rendersAuthMethodType } from '../methods/log-in.methods-decorator';
|
import { rendersAuthMethodType } from '../methods/log-in.methods-decorator';
|
||||||
import { AuthMethod } from '../../../core/auth/models/auth.method';
|
import { AuthMethod } from '../../../core/auth/models/auth.method';
|
||||||
|
|
||||||
@@ -27,12 +26,9 @@ export class LogInContainerComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
public objectInjector: Injector;
|
public objectInjector: Injector;
|
||||||
|
|
||||||
/**
|
constructor(
|
||||||
* Initialize instance variables
|
protected injector: Injector,
|
||||||
*
|
) {
|
||||||
* @param {Injector} injector
|
|
||||||
*/
|
|
||||||
constructor(private injector: Injector) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -51,8 +47,8 @@ export class LogInContainerComponent implements OnInit {
|
|||||||
/**
|
/**
|
||||||
* Find the correct component based on the AuthMethod's type
|
* Find the correct component based on the AuthMethod's type
|
||||||
*/
|
*/
|
||||||
getAuthMethodContent(): string {
|
getAuthMethodContent(): Type<Component> {
|
||||||
return rendersAuthMethodType(this.authMethod.authMethodType);
|
return rendersAuthMethodType(this.authMethod.authMethodType);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,11 +1,7 @@
|
|||||||
<ds-themed-loading *ngIf="(loading | async) || (isAuthenticated | async)" class="m-5"></ds-themed-loading>
|
<ds-themed-loading *ngIf="(loading | async) || (isAuthenticated | async)" class="m-5"></ds-themed-loading>
|
||||||
<div *ngIf="!(loading | async) && !(isAuthenticated | async)" class="px-4 py-3 mx-auto login-container">
|
<div *ngIf="!(loading | async) && !(isAuthenticated | async)" class="px-4 py-3 mx-auto login-container">
|
||||||
<ng-container *ngFor="let authMethod of getOrderedAuthMethods(authMethods | async); let last = last">
|
<ng-container *ngFor="let authMethod of (authMethods | async); let last = last">
|
||||||
<div [class.d-none]="contentRef.innerText?.trim().length === 0">
|
<ds-log-in-container [authMethod]="authMethod" [isStandalonePage]="isStandalonePage"></ds-log-in-container>
|
||||||
<div #contentRef>
|
<div *ngIf="!last" class="dropdown-divider my-2"></div>
|
||||||
<ds-log-in-container [authMethod]="authMethod" [isStandalonePage]="isStandalonePage"></ds-log-in-container>
|
|
||||||
</div>
|
|
||||||
<div *ngIf="!last" class="dropdown-divider my-2"></div>
|
|
||||||
</div>
|
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -11,12 +11,8 @@ import {
|
|||||||
import { hasValue } from '../empty.util';
|
import { hasValue } from '../empty.util';
|
||||||
import { AuthService } from '../../core/auth/auth.service';
|
import { AuthService } from '../../core/auth/auth.service';
|
||||||
import { CoreState } from '../../core/core-state.model';
|
import { CoreState } from '../../core/core-state.model';
|
||||||
import { AuthMethodType } from '../../core/auth/models/auth.method-type';
|
import { rendersAuthMethodType } from './methods/log-in.methods-decorator';
|
||||||
|
|
||||||
/**
|
|
||||||
* /users/sign-in
|
|
||||||
* @class LogInComponent
|
|
||||||
*/
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-log-in',
|
selector: 'ds-log-in',
|
||||||
templateUrl: './log-in.component.html',
|
templateUrl: './log-in.component.html',
|
||||||
@@ -57,8 +53,10 @@ export class LogInComponent implements OnInit {
|
|||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.authMethods = this.store.pipe(
|
this.authMethods = this.store.pipe(
|
||||||
select(getAuthenticationMethods),
|
select(getAuthenticationMethods),
|
||||||
// ignore the ip authentication method when it's returned by the backend
|
map((methods: AuthMethod[]) => methods
|
||||||
map((methods: AuthMethod[]) => methods.filter((authMethod: AuthMethod) => authMethod.authMethodType !== AuthMethodType.Ip)),
|
.filter((authMethod: AuthMethod) => rendersAuthMethodType(authMethod.authMethodType) !== undefined)
|
||||||
|
.sort((method1: AuthMethod, method2: AuthMethod) => method1.position - method2.position)
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
// set loading
|
// set loading
|
||||||
@@ -75,16 +73,4 @@ export class LogInComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an ordered list of {@link AuthMethod}s based on their position.
|
|
||||||
*
|
|
||||||
* @param authMethods The {@link AuthMethod}s to sort
|
|
||||||
*/
|
|
||||||
getOrderedAuthMethods(authMethods: AuthMethod[] | null): AuthMethod[] {
|
|
||||||
if (hasValue(authMethods)) {
|
|
||||||
return [...authMethods].sort((method1: AuthMethod, method2: AuthMethod) => method1.position - method2.position);
|
|
||||||
} else {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
|
import { Component, Type } from '@angular/core';
|
||||||
import { AuthMethodType } from '../../../core/auth/models/auth.method-type';
|
import { AuthMethodType } from '../../../core/auth/models/auth.method-type';
|
||||||
|
|
||||||
const authMethodsMap = new Map();
|
const authMethodsMap: Map<AuthMethodType, Type<Component>> = new Map();
|
||||||
|
|
||||||
export function renderAuthMethodFor(authMethodType: AuthMethodType) {
|
export function renderAuthMethodFor(authMethodType: AuthMethodType) {
|
||||||
return function decorator(objectElement: any) {
|
return function decorator(objectElement: any) {
|
||||||
@@ -11,6 +12,6 @@ export function renderAuthMethodFor(authMethodType: AuthMethodType) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function rendersAuthMethodType(authMethodType: AuthMethodType) {
|
export function rendersAuthMethodType(authMethodType: AuthMethodType): Type<Component> | undefined {
|
||||||
return authMethodsMap.get(authMethodType);
|
return authMethodsMap.get(authMethodType);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user