mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 10:34:15 +00:00
Added Action to set isStandAlonePage in store
This commit is contained in:
@@ -8,3 +8,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@@ -10,7 +10,7 @@ import {
|
|||||||
AddAuthenticationMessageAction,
|
AddAuthenticationMessageAction,
|
||||||
AuthenticatedAction,
|
AuthenticatedAction,
|
||||||
AuthenticationSuccessAction,
|
AuthenticationSuccessAction,
|
||||||
ResetAuthenticationMessagesAction
|
ResetAuthenticationMessagesAction, SetIsStandalonePageInAuthMethodsAction
|
||||||
} from '../core/auth/auth.actions';
|
} from '../core/auth/auth.actions';
|
||||||
import { hasValue, isNotEmpty } from '../shared/empty.util';
|
import { hasValue, isNotEmpty } from '../shared/empty.util';
|
||||||
import { AuthTokenInfo } from '../core/auth/models/auth-token-info.model';
|
import { AuthTokenInfo } from '../core/auth/models/auth-token-info.model';
|
||||||
@@ -79,4 +79,5 @@ export class LoginPageComponent implements OnDestroy, OnInit {
|
|||||||
// Clear all authentication messages when leaving login page
|
// Clear all authentication messages when leaving login page
|
||||||
this.store.dispatch(new ResetAuthenticationMessagesAction());
|
this.store.dispatch(new ResetAuthenticationMessagesAction());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -23,6 +23,7 @@ export const AuthActionTypes = {
|
|||||||
RETRIEVE_AUTH_METHODS: type('dspace/auth/RETRIEVE_AUTH_METHODS'),
|
RETRIEVE_AUTH_METHODS: type('dspace/auth/RETRIEVE_AUTH_METHODS'),
|
||||||
RETRIEVE_AUTH_METHODS_SUCCESS: type('dspace/auth/RETRIEVE_AUTH_METHODS_SUCCESS'),
|
RETRIEVE_AUTH_METHODS_SUCCESS: type('dspace/auth/RETRIEVE_AUTH_METHODS_SUCCESS'),
|
||||||
RETRIEVE_AUTH_METHODS_ERROR: type('dspace/auth/RETRIEVE_AUTH_METHODS_ERROR'),
|
RETRIEVE_AUTH_METHODS_ERROR: type('dspace/auth/RETRIEVE_AUTH_METHODS_ERROR'),
|
||||||
|
SET_IS_STANDALONE_PAGE_IN_AUTH_METHODS: type('dspace/auth/SET_IS_STANDALONE_PAGE_IN_AUTH_METHODS'),
|
||||||
REDIRECT_TOKEN_EXPIRED: type('dspace/auth/REDIRECT_TOKEN_EXPIRED'),
|
REDIRECT_TOKEN_EXPIRED: type('dspace/auth/REDIRECT_TOKEN_EXPIRED'),
|
||||||
REDIRECT_AUTHENTICATION_REQUIRED: type('dspace/auth/REDIRECT_AUTHENTICATION_REQUIRED'),
|
REDIRECT_AUTHENTICATION_REQUIRED: type('dspace/auth/REDIRECT_AUTHENTICATION_REQUIRED'),
|
||||||
REFRESH_TOKEN: type('dspace/auth/REFRESH_TOKEN'),
|
REFRESH_TOKEN: type('dspace/auth/REFRESH_TOKEN'),
|
||||||
@@ -374,6 +375,15 @@ export class RetrieveAuthMethodsErrorAction implements Action {
|
|||||||
public type: string = AuthActionTypes.RETRIEVE_AUTH_METHODS_ERROR;
|
public type: string = AuthActionTypes.RETRIEVE_AUTH_METHODS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class SetIsStandalonePageInAuthMethodsAction implements Action {
|
||||||
|
type: string = AuthActionTypes.SET_IS_STANDALONE_PAGE_IN_AUTH_METHODS;
|
||||||
|
payload: boolean;
|
||||||
|
|
||||||
|
constructor(isStandAlonePage: boolean) {
|
||||||
|
this.payload = isStandAlonePage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change the redirect url.
|
* Change the redirect url.
|
||||||
* @class SetRedirectUrlAction
|
* @class SetRedirectUrlAction
|
||||||
@@ -413,4 +423,5 @@ export type AuthActions
|
|||||||
| ResetAuthenticationMessagesAction
|
| ResetAuthenticationMessagesAction
|
||||||
| RetrieveAuthMethodsAction
|
| RetrieveAuthMethodsAction
|
||||||
| RetrieveAuthMethodsSuccessAction
|
| RetrieveAuthMethodsSuccessAction
|
||||||
|
| SetIsStandalonePageInAuthMethodsAction
|
||||||
| RetrieveAuthMethodsErrorAction;
|
| RetrieveAuthMethodsErrorAction;
|
||||||
|
@@ -8,13 +8,14 @@ import {
|
|||||||
LogOutErrorAction,
|
LogOutErrorAction,
|
||||||
RedirectWhenAuthenticationIsRequiredAction,
|
RedirectWhenAuthenticationIsRequiredAction,
|
||||||
RedirectWhenTokenExpiredAction,
|
RedirectWhenTokenExpiredAction,
|
||||||
RefreshTokenSuccessAction, RetrieveAuthMethodsSuccessAction,
|
RefreshTokenSuccessAction, RetrieveAuthMethodsSuccessAction, SetIsStandalonePageInAuthMethodsAction,
|
||||||
SetRedirectUrlAction
|
SetRedirectUrlAction
|
||||||
} from './auth.actions';
|
} from './auth.actions';
|
||||||
// import models
|
// import models
|
||||||
import { EPerson } from '../eperson/models/eperson.model';
|
import { EPerson } from '../eperson/models/eperson.model';
|
||||||
import { AuthTokenInfo } from './models/auth-token-info.model';
|
import { AuthTokenInfo } from './models/auth-token-info.model';
|
||||||
import { AuthMethodModel } from './models/auth-method.model';
|
import { AuthMethodModel } from './models/auth-method.model';
|
||||||
|
import { AuthMethodType } from '../../shared/log-in/methods/authMethods-type';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The auth state.
|
* The auth state.
|
||||||
@@ -219,6 +220,16 @@ export function authReducer(state: any = initialState, action: AuthActions): Aut
|
|||||||
authMethods: (action as RetrieveAuthMethodsSuccessAction).payload
|
authMethods: (action as RetrieveAuthMethodsSuccessAction).payload
|
||||||
});
|
});
|
||||||
|
|
||||||
|
case AuthActionTypes.SET_IS_STANDALONE_PAGE_IN_AUTH_METHODS:
|
||||||
|
const authMethods: AuthMethodModel[] = state.authMethods;
|
||||||
|
const newAuthMethods: AuthMethodModel[] = new Array<AuthMethodModel>();
|
||||||
|
const isStandAlonePage: boolean = (action as SetIsStandalonePageInAuthMethodsAction).payload;
|
||||||
|
for (const authMethod of authMethods) {
|
||||||
|
const newAuthMethod = new AuthMethodModel(authMethod.authMethodType, authMethod.location, isStandAlonePage);
|
||||||
|
newAuthMethods.push(newAuthMethod);
|
||||||
|
}
|
||||||
|
return Object.assign({}, state, {authMethods: newAuthMethods});
|
||||||
|
|
||||||
case AuthActionTypes.RETRIEVE_AUTH_METHODS_ERROR:
|
case AuthActionTypes.RETRIEVE_AUTH_METHODS_ERROR:
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
loading: false
|
loading: false
|
||||||
|
@@ -6,7 +6,7 @@ export class AuthMethodModel {
|
|||||||
location?: string;
|
location?: string;
|
||||||
isStandalonePage? = true;
|
isStandalonePage? = true;
|
||||||
|
|
||||||
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;
|
||||||
|
@@ -1,13 +0,0 @@
|
|||||||
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,12 +1,12 @@
|
|||||||
import { Component, Injector, Input, OnDestroy, OnInit } from '@angular/core';
|
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
|
||||||
import { Observable, Subscription } from 'rxjs';
|
import { Observable } 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';
|
import { filter, takeWhile, } from 'rxjs/operators';
|
||||||
import { filter, takeWhile, tap } from 'rxjs/operators';
|
|
||||||
import { AuthService } from '../../core/auth/auth.service';
|
import { AuthService } from '../../core/auth/auth.service';
|
||||||
|
import { SetIsStandalonePageInAuthMethodsAction } from '../../core/auth/auth.actions';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-log-in',
|
selector: 'ds-log-in',
|
||||||
@@ -20,10 +20,6 @@ export class LogInComponent implements OnInit, OnDestroy {
|
|||||||
*/
|
*/
|
||||||
@Input() authMethodData: Observable<AuthMethodModel[]>;
|
@Input() authMethodData: Observable<AuthMethodModel[]>;
|
||||||
|
|
||||||
// private authMethods: AuthMethodModel[];
|
|
||||||
|
|
||||||
// public injectedAuthMethods: InjectedAuthMethodModel[];
|
|
||||||
|
|
||||||
@Input() isStandalonePage: boolean;
|
@Input() isStandalonePage: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -44,26 +40,17 @@ export class LogInComponent implements OnInit, OnDestroy {
|
|||||||
*/
|
*/
|
||||||
private alive = true;
|
private alive = true;
|
||||||
|
|
||||||
private subscription: Subscription;
|
|
||||||
|
|
||||||
constructor(private store: Store<CoreState>,
|
constructor(private store: Store<CoreState>,
|
||||||
private authService: AuthService,) {
|
private authService: AuthService,) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
|
||||||
|
this.store.dispatch(new SetIsStandalonePageInAuthMethodsAction(this.isStandalonePage));
|
||||||
|
|
||||||
this.authMethodData = this.store.pipe(
|
this.authMethodData = this.store.pipe(
|
||||||
select(getAuthenticationMethods)
|
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);
|
|
||||||
}
|
|
||||||
console.log('injectedAuthMethods in ngOnInit(): ', this.injectedAuthMethods);
|
|
||||||
*/
|
|
||||||
|
|
||||||
// set loading
|
// set loading
|
||||||
this.loading = this.store.pipe(select(isAuthenticationLoading));
|
this.loading = this.store.pipe(select(isAuthenticationLoading));
|
||||||
@@ -84,7 +71,6 @@ export class LogInComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
// this.subscription.unsubscribe();
|
|
||||||
this.alive = false;
|
this.alive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user