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