mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 10:34:15 +00:00
Fix display order of authentication methods
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { select, Store } from '@ngrx/store';
|
||||
import { AuthMethod } from '../../core/auth/models/auth.method';
|
||||
@@ -8,11 +8,8 @@ import {
|
||||
isAuthenticated,
|
||||
isAuthenticationLoading
|
||||
} from '../../core/auth/selectors';
|
||||
import { getForgotPasswordRoute, getRegisterRoute } from '../../app-routing-paths';
|
||||
import { hasValue } from '../empty.util';
|
||||
import { AuthService } from '../../core/auth/auth.service';
|
||||
import { AuthorizationDataService } from '../../core/data/feature-authorization/authorization-data.service';
|
||||
import { FeatureID } from '../../core/data/feature-authorization/feature-id';
|
||||
import { CoreState } from '../../core/core-state.model';
|
||||
|
||||
/**
|
||||
@@ -22,7 +19,8 @@ import { CoreState } from '../../core/core-state.model';
|
||||
@Component({
|
||||
selector: 'ds-log-in',
|
||||
templateUrl: './log-in.component.html',
|
||||
styleUrls: ['./log-in.component.scss']
|
||||
styleUrls: ['./log-in.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class LogInComponent implements OnInit {
|
||||
|
||||
@@ -50,14 +48,9 @@ export class LogInComponent implements OnInit {
|
||||
*/
|
||||
public loading: Observable<boolean>;
|
||||
|
||||
/**
|
||||
* Whether or not the current user (or anonymous) is authorized to register an account
|
||||
*/
|
||||
canRegister$: Observable<boolean>;
|
||||
|
||||
constructor(private store: Store<CoreState>,
|
||||
private authService: AuthService,
|
||||
private authorizationService: AuthorizationDataService) {
|
||||
) {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
@@ -78,15 +71,18 @@ export class LogInComponent implements OnInit {
|
||||
this.authService.clearRedirectUrl();
|
||||
}
|
||||
});
|
||||
|
||||
this.canRegister$ = this.authorizationService.isAuthorized(FeatureID.EPersonRegistration);
|
||||
}
|
||||
|
||||
getRegisterRoute() {
|
||||
return getRegisterRoute();
|
||||
}
|
||||
|
||||
getForgotRoute() {
|
||||
return getForgotPasswordRoute();
|
||||
/**
|
||||
* 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 [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user