mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Boolean isStandalonePage injected
This commit is contained in:
@@ -341,10 +341,10 @@ export class ResetAuthenticationMessagesAction implements Action {
|
||||
public type: string = AuthActionTypes.RESET_MESSAGES;
|
||||
}
|
||||
|
||||
// Next three Actions are used by shibboleth login
|
||||
// // Next three Actions are used by dynamic login methods
|
||||
/**
|
||||
* Check if token is already present upon initial load.
|
||||
* @class CheckAuthenticationTokenAction
|
||||
* Action that triggers an effect fetching the authentication methods enabled ant the backend
|
||||
* @class RetrieveAuthMethodsAction
|
||||
* @implements {Action}
|
||||
*/
|
||||
export class RetrieveAuthMethodsAction implements Action {
|
||||
|
@@ -4,8 +4,9 @@ import { ShibbConstants } from '../../../+login-page/shibbolethTargetPage/const/
|
||||
export class AuthMethodModel {
|
||||
authMethodType: AuthMethodType;
|
||||
location?: string;
|
||||
isStandalonePage?: boolean;
|
||||
|
||||
constructor(authMethodName: string, location?: string) {
|
||||
constructor(authMethodName: string, location?: string, isStandAlonePage?: boolean) {
|
||||
switch (authMethodName) {
|
||||
case 'ip': {
|
||||
this.authMethodType = AuthMethodType.Ip;
|
||||
@@ -19,9 +20,6 @@ export class AuthMethodModel {
|
||||
this.authMethodType = AuthMethodType.Shibboleth;
|
||||
const strings: string[] = location.split('target=');
|
||||
const target = strings[1];
|
||||
|
||||
console.log('strings', strings);
|
||||
|
||||
this.location = target + location + '/' + ShibbConstants.SHIBBOLETH_REDIRECT_ROUTE;
|
||||
break;
|
||||
}
|
||||
@@ -31,6 +29,7 @@ export class AuthMethodModel {
|
||||
}
|
||||
case 'password': {
|
||||
this.authMethodType = AuthMethodType.Password;
|
||||
this.isStandalonePage = true;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@@ -1,3 +1,5 @@
|
||||
<ng-container *ngComponentOutlet="getAuthMethodContent(); injector: objectInjector;">
|
||||
<ng-container
|
||||
*ngComponentOutlet="getAuthMethodContent();
|
||||
injector: objectInjector;">
|
||||
</ng-container>
|
||||
|
||||
|
@@ -3,6 +3,7 @@ import { rendersAuthMethodType } from '../methods/authMethods-decorator';
|
||||
import { AuthMethodModel } from '../../../core/auth/models/auth-method.model';
|
||||
import { select, Store } from '@ngrx/store';
|
||||
import { CoreState } from '../../../core/core.reducers';
|
||||
import { InjectedAuthMethodModel } from '../injectedAuthMethodModel/injectedAuthMethodModel';
|
||||
|
||||
/**
|
||||
* This component represents a section that contains the submission license form.
|
||||
@@ -14,7 +15,7 @@ import { CoreState } from '../../../core/core.reducers';
|
||||
})
|
||||
export class LoginContainerComponent implements OnInit {
|
||||
|
||||
@Input() authMethodModel: AuthMethodModel;
|
||||
@Input() authMethodModel: InjectedAuthMethodModel;
|
||||
|
||||
/**
|
||||
* Injector to inject a section component with the @Input parameters
|
||||
|
@@ -0,0 +1,13 @@
|
||||
import { AuthMethodType } from '../../../shared/log-in/methods/authMethods-type';
|
||||
|
||||
export class InjectedAuthMethodModel {
|
||||
authMethodType: AuthMethodType;
|
||||
location?: string;
|
||||
isStandalonePage?: boolean;
|
||||
|
||||
constructor(authMethodName: AuthMethodType, location?: string, isStandAlonePage?: boolean) {
|
||||
this.authMethodType = authMethodName;
|
||||
this.location = location;
|
||||
this.isStandalonePage = isStandAlonePage;
|
||||
}
|
||||
}
|
@@ -1,4 +1,5 @@
|
||||
<ds-loading *ngIf="(loading | async) || (isAuthenticated | async)" class="m-5"></ds-loading>
|
||||
<ng-container *ngFor="let authMethodModel of (authMethodData | async)">
|
||||
<ds-login-container [authMethodModel]="authMethodModel"></ds-login-container>
|
||||
<ng-container *ngFor="let authMethodModel of injectedAuthMethods">
|
||||
<ds-login-container
|
||||
[authMethodModel]="authMethodModel"></ds-login-container>
|
||||
</ng-container>
|
||||
|
@@ -1,22 +1,27 @@
|
||||
import { Component, Injector, Input, OnInit } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Component, Injector, Input, OnDestroy, OnInit } from '@angular/core';
|
||||
import { Observable, Subscription } from 'rxjs';
|
||||
import { AuthMethodModel } from '../../core/auth/models/auth-method.model';
|
||||
import { select, Store } from '@ngrx/store';
|
||||
import { getAuthenticationMethods, isAuthenticated, isAuthenticationLoading } from '../../core/auth/selectors';
|
||||
import { CoreState } from '../../core/core.reducers';
|
||||
import { InjectedAuthMethodModel } from './injectedAuthMethodModel/injectedAuthMethodModel';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-log-in',
|
||||
templateUrl: './log-in.component.html',
|
||||
styleUrls: ['./log-in.component.scss']
|
||||
})
|
||||
export class LogInComponent implements OnInit {
|
||||
export class LogInComponent implements OnInit, OnDestroy {
|
||||
/**
|
||||
* The authentication methods data
|
||||
* @type {AuthMethodModel[]}
|
||||
*/
|
||||
@Input() authMethodData: Observable<AuthMethodModel[]>;
|
||||
|
||||
private authMethods: AuthMethodModel[];
|
||||
|
||||
private injectedAuthMethods: InjectedAuthMethodModel[];
|
||||
|
||||
@Input() isStandalonePage: boolean;
|
||||
|
||||
/**
|
||||
@@ -30,6 +35,7 @@ export class LogInComponent implements OnInit {
|
||||
* @type {boolean}
|
||||
*/
|
||||
public loading: Observable<boolean>;
|
||||
private subscription: Subscription;
|
||||
|
||||
constructor(private store: Store<CoreState>) {
|
||||
}
|
||||
@@ -37,6 +43,14 @@ export class LogInComponent implements OnInit {
|
||||
ngOnInit(): void {
|
||||
this.authMethodData = this.store.pipe(select(getAuthenticationMethods));
|
||||
|
||||
this.subscription = this.authMethodData.subscribe((methods) => this.authMethods = methods);
|
||||
this.injectedAuthMethods = new Array<InjectedAuthMethodModel>();
|
||||
// tslint:disable-next-line:forin
|
||||
for (const index in this.authMethods) {
|
||||
const injectedAuthMethod = new InjectedAuthMethodModel(this.authMethods[index].authMethodType, this.authMethods[index].location, this.isStandalonePage);
|
||||
this.injectedAuthMethods.push(injectedAuthMethod);
|
||||
}
|
||||
|
||||
// set loading
|
||||
this.loading = this.store.pipe(select(isAuthenticationLoading));
|
||||
|
||||
@@ -44,4 +58,8 @@ export class LogInComponent implements OnInit {
|
||||
this.isAuthenticated = this.store.pipe(select(isAuthenticated));
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.subscription.unsubscribe();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { filter, map, takeWhile } from 'rxjs/operators';
|
||||
import { Component, OnDestroy, OnInit } from '@angular/core';
|
||||
import { Component, Inject, Input, OnDestroy, OnInit } from '@angular/core';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
|
||||
import { select, Store } from '@ngrx/store';
|
||||
@@ -22,6 +22,7 @@ import { fadeOut } from '../../../animations/fade';
|
||||
import { AuthService } from '../../../../core/auth/auth.service';
|
||||
import { AuthMethodType } from '../authMethods-type';
|
||||
import { renderAuthMethodFor } from '../authMethods-decorator';
|
||||
import { AuthMethodModel } from '../../../../core/auth/models/auth-method.model';
|
||||
|
||||
/**
|
||||
* /users/sign-in
|
||||
@@ -84,6 +85,8 @@ export class LogInPasswordComponent implements OnDestroy, OnInit {
|
||||
*/
|
||||
private alive = true;
|
||||
|
||||
@Input() authMethodModel: AuthMethodModel;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {AuthService} authService
|
||||
@@ -91,10 +94,12 @@ export class LogInPasswordComponent implements OnDestroy, OnInit {
|
||||
* @param {Store<State>} store
|
||||
*/
|
||||
constructor(
|
||||
@Inject('authMethodModelProvider') public injectedAuthMethodModel: AuthMethodModel,
|
||||
private authService: AuthService,
|
||||
private formBuilder: FormBuilder,
|
||||
private store: Store<CoreState>,
|
||||
private store: Store<CoreState>
|
||||
) {
|
||||
this.authMethodModel = injectedAuthMethodModel;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,7 +107,6 @@ export class LogInPasswordComponent implements OnDestroy, OnInit {
|
||||
* @method ngOnInit
|
||||
*/
|
||||
public ngOnInit() {
|
||||
|
||||
// set isAuthenticated
|
||||
this.isAuthenticated = this.store.pipe(select(isAuthenticated));
|
||||
|
||||
@@ -139,7 +143,7 @@ export class LogInPasswordComponent implements OnDestroy, OnInit {
|
||||
takeWhile(() => this.alive),
|
||||
filter((authenticated) => authenticated))
|
||||
.subscribe(() => {
|
||||
this.authService.redirectAfterLoginSuccess(true); // HARDCODED FOR DEV _ CHANGE IT
|
||||
this.authService.redirectAfterLoginSuccess(this.authMethodModel.isStandalonePage);
|
||||
}
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user