mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 10:34:15 +00:00
Test if reopening PR works
This commit is contained in:
@@ -11,6 +11,7 @@ import { AuthMethodModel } from './models/auth-method.model';
|
|||||||
|
|
||||||
export const AuthActionTypes = {
|
export const AuthActionTypes = {
|
||||||
AUTHENTICATE: type('dspace/auth/AUTHENTICATE'),
|
AUTHENTICATE: type('dspace/auth/AUTHENTICATE'),
|
||||||
|
START_SHIBBOLETH_AUTHENTICATION: type('dspace/auth/START_SHIBBOLETH_AUTHENTICATION'),
|
||||||
GET_JWT_AFTER_SHIBB_LOGIN: type('dspace/auth/GET_JWT_AFTER_SHIBB_LOGIN'),
|
GET_JWT_AFTER_SHIBB_LOGIN: type('dspace/auth/GET_JWT_AFTER_SHIBB_LOGIN'),
|
||||||
AUTHENTICATE_ERROR: type('dspace/auth/AUTHENTICATE_ERROR'),
|
AUTHENTICATE_ERROR: type('dspace/auth/AUTHENTICATE_ERROR'),
|
||||||
AUTHENTICATE_SUCCESS: type('dspace/auth/AUTHENTICATE_SUCCESS'),
|
AUTHENTICATE_SUCCESS: type('dspace/auth/AUTHENTICATE_SUCCESS'),
|
||||||
@@ -57,6 +58,20 @@ export class AuthenticateAction implements Action {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Authenticate.
|
||||||
|
* @class StartShibbolethAuthenticationAction
|
||||||
|
* @implements {Action}
|
||||||
|
*/
|
||||||
|
export class StartShibbolethAuthenticationAction implements Action {
|
||||||
|
public type: string = AuthActionTypes.START_SHIBBOLETH_AUTHENTICATION;
|
||||||
|
payload: AuthMethodModel;
|
||||||
|
|
||||||
|
constructor(authMethodModel: AuthMethodModel) {
|
||||||
|
this.payload = authMethodModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GetJWTafterShibbLoginAction.
|
* GetJWTafterShibbLoginAction.
|
||||||
* @class GetJWTafterShibbLoginAction
|
* @class GetJWTafterShibbLoginAction
|
||||||
|
@@ -30,7 +30,7 @@ import {
|
|||||||
RetrieveAuthMethodsAction,
|
RetrieveAuthMethodsAction,
|
||||||
RetrieveAuthMethodsErrorAction,
|
RetrieveAuthMethodsErrorAction,
|
||||||
RetrieveAuthMethodsSuccessAction,
|
RetrieveAuthMethodsSuccessAction,
|
||||||
GetJWTafterShibbLoginAction
|
GetJWTafterShibbLoginAction, StartShibbolethAuthenticationAction
|
||||||
} from './auth.actions';
|
} from './auth.actions';
|
||||||
import { EPerson } from '../eperson/models/eperson.model';
|
import { EPerson } from '../eperson/models/eperson.model';
|
||||||
import { AuthStatus } from './models/auth-status.model';
|
import { AuthStatus } from './models/auth-status.model';
|
||||||
@@ -58,6 +58,22 @@ export class AuthEffects {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Authenticate user.
|
||||||
|
* @method authenticate
|
||||||
|
*/
|
||||||
|
/* @Effect()
|
||||||
|
public shibbolethAuthenticate$: Observable<Action> = this.actions$.pipe(
|
||||||
|
ofType(AuthActionTypes.START_SHIBBOLETH_AUTHENTICATION),
|
||||||
|
switchMap((action: StartShibbolethAuthenticationAction) => {
|
||||||
|
return this.authService.authenticate(action.payload.location).pipe(
|
||||||
|
take(1),
|
||||||
|
map((response: AuthStatus) => new AuthenticationSuccessAction(response.token)),
|
||||||
|
catchError((error) => observableOf(new AuthenticationErrorAction(error)))
|
||||||
|
);
|
||||||
|
})
|
||||||
|
);*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shib Login.
|
* Shib Login.
|
||||||
* @method shibLogin
|
* @method shibLogin
|
||||||
|
@@ -80,6 +80,13 @@ export function authReducer(state: any = initialState, action: AuthActions): Aut
|
|||||||
info: undefined
|
info: undefined
|
||||||
});
|
});
|
||||||
|
|
||||||
|
case AuthActionTypes.START_SHIBBOLETH_AUTHENTICATION:
|
||||||
|
return Object.assign({}, state, {
|
||||||
|
error: undefined,
|
||||||
|
loading: true,
|
||||||
|
info: undefined
|
||||||
|
});
|
||||||
|
|
||||||
case AuthActionTypes.GET_JWT_AFTER_SHIBB_LOGIN:
|
case AuthActionTypes.GET_JWT_AFTER_SHIBB_LOGIN:
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
error: undefined,
|
error: undefined,
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
<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 (authMethodData | async)">
|
||||||
<ds-login-container [authMethodModel]="authMethodModel"></ds-login-container>
|
<ds-login-container [authMethodModel]="authMethodModel"></ds-login-container>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import { Component, Injector, Input, OnInit } from '@angular/core';
|
import { Component, Injector, Input, OnInit } from '@angular/core';
|
||||||
import { Observable } 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 { Store } from '@ngrx/store';
|
import { select, Store } from '@ngrx/store';
|
||||||
import { AuthState } from '../../core/auth/auth.reducer';
|
import { getAuthenticationMethods, isAuthenticated, isAuthenticationLoading } from '../../core/auth/selectors';
|
||||||
import { getAuthenticationMethods } from '../../core/auth/selectors';
|
import { CoreState } from '../../core/core.reducers';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-auth-methods',
|
selector: 'ds-auth-methods',
|
||||||
@@ -17,11 +17,29 @@ export class AuthMethodsComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
@Input() authMethodData: Observable<AuthMethodModel[]>;
|
@Input() authMethodData: Observable<AuthMethodModel[]>;
|
||||||
|
|
||||||
constructor( private store: Store<AuthState>) {
|
/**
|
||||||
|
* Whether user is authenticated.
|
||||||
|
* @type {Observable<string>}
|
||||||
|
*/
|
||||||
|
public isAuthenticated: Observable<boolean>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* True if the authentication is loading.
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
|
public loading: Observable<boolean>;
|
||||||
|
|
||||||
|
constructor( private store: Store<CoreState>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.authMethodData = this.authMethodData = this.store.select(getAuthenticationMethods);
|
this.authMethodData = this.authMethodData = this.store.select(getAuthenticationMethods);
|
||||||
|
|
||||||
|
// set loading
|
||||||
|
this.loading = this.store.pipe(select(isAuthenticationLoading));
|
||||||
|
|
||||||
|
// set isAuthenticated
|
||||||
|
this.isAuthenticated = this.store.pipe(select(isAuthenticated));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,2 +1,3 @@
|
|||||||
<ng-container *ngComponentOutlet="getAuthMethodContent(); injector: objectInjector;"></ng-container>
|
<ng-container *ngComponentOutlet="getAuthMethodContent(); injector: objectInjector;">
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
@@ -1,11 +1,13 @@
|
|||||||
import { Component, Injector, Input, OnInit, ViewChild } from '@angular/core';
|
import { Component, ContentChild, Injector, Input, OnInit, ViewChild, ViewChildren } from '@angular/core';
|
||||||
import { rendersAuthMethodType } from '../authMethods-decorator';
|
import { rendersAuthMethodType } from '../authMethods-decorator';
|
||||||
import { AuthMethodModel } from '../../../core/auth/models/auth-method.model';
|
import { AuthMethodModel } from '../../../core/auth/models/auth-method.model';
|
||||||
import { getAuthenticationMethods } from '../../../core/auth/selectors';
|
import { getAuthenticationMethods, isAuthenticated, isAuthenticationLoading } from '../../../core/auth/selectors';
|
||||||
import { Store } from '@ngrx/store';
|
import { select, Store } from '@ngrx/store';
|
||||||
import { AppState } from '../../../app.reducer';
|
import { AppState } from '../../../app.reducer';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { AuthMethodType } from '../authMethods-type';
|
import { AuthMethodType } from '../authMethods-type';
|
||||||
|
import { CoreState } from '../../../core/core.reducers';
|
||||||
|
import { ShibbolethComponent } from '../../../+login-page/shibbolethTargetPage/shibboleth.component';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This component represents a section that contains the submission license form.
|
* This component represents a section that contains the submission license form.
|
||||||
@@ -30,7 +32,7 @@ export class LoginContainerComponent implements OnInit {
|
|||||||
*
|
*
|
||||||
* @param {Injector} injector
|
* @param {Injector} injector
|
||||||
*/
|
*/
|
||||||
constructor(private injector: Injector) {
|
constructor(private injector: Injector, private store: Store<CoreState>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -44,12 +46,20 @@ export class LoginContainerComponent implements OnInit {
|
|||||||
parent: this.injector
|
parent: this.injector
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find the correct component based on the authMethod's type
|
* Find the correct component based on the AuthMethod's type
|
||||||
*/
|
*/
|
||||||
getAuthMethodContent(): string {
|
getAuthMethodContent(): string {
|
||||||
return rendersAuthMethodType(this.authMethodModel.authMethodType)
|
return rendersAuthMethodType(this.authMethodModel.authMethodType)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
startShibbolethAuthentication($event) {
|
||||||
|
console.log('startShibbolethAuthentication() was called with event: ', $event);
|
||||||
|
// this.store.dispatch(new ShibbolethAuthenticateAction());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
<ds-loading *ngIf="(loading | async) || (isAuthenticated | async)" class="m-5"></ds-loading>
|
|
||||||
<form *ngIf="!(loading | async) && !(isAuthenticated | async)" class="form-login px-4 py-3" (ngSubmit)="submit()"
|
<form *ngIf="!(loading | async) && !(isAuthenticated | async)" class="form-login px-4 py-3" (ngSubmit)="submit()"
|
||||||
[formGroup]="form" novalidate>
|
[formGroup]="form" novalidate>
|
||||||
<label for="inputEmail" class="sr-only">{{"login.form.email" | translate}}</label>
|
<label for="inputEmail" class="sr-only">{{"login.form.email" | translate}}</label>
|
||||||
|
@@ -1,13 +1,4 @@
|
|||||||
<div>
|
<form *ngIf="!(loading | async) && !(isAuthenticated | async)"class="form-login px-4 py-3" (ngSubmit)="submit()"
|
||||||
<a class="btn btn-lg btn-primary btn-block mt-3" type="submit"
|
|
||||||
[href]="buttonHref"
|
|
||||||
role="button"
|
|
||||||
>{{"login.shibboleth" | translate}}</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<!--<form *ngIf="!(loading | async) && !(isAuthenticated | async)" class="form-login px-4 py-3" (ngSubmit)="submit()"-->
|
|
||||||
<form class="form-login px-4 py-3" (ngSubmit)="submit()"
|
|
||||||
[formGroup]="shibbForm" novalidate>
|
[formGroup]="shibbForm" novalidate>
|
||||||
<button class="btn btn-lg btn-primary btn-block mt-3" type="submit"
|
<button class="btn btn-lg btn-primary btn-block mt-3" type="submit"
|
||||||
[disabled]="!shibbForm.valid">{{"login.shibbForm.submit" | translate}}</button>
|
[disabled]="!shibbForm.valid">{{"login.shibbForm.submit" | translate}}</button>
|
||||||
|
@@ -1,8 +1,13 @@
|
|||||||
import { Component, Inject, Input, OnInit } from '@angular/core';
|
import { Component, EventEmitter, Inject, Input, OnInit, Output, QueryList, ViewChildren } from '@angular/core';
|
||||||
import { renderAuthMethodFor } from '../../authMethods-decorator';
|
import { renderAuthMethodFor } from '../../authMethods-decorator';
|
||||||
import { AuthMethodType } from '../../authMethods-type';
|
import { AuthMethodType } from '../../authMethods-type';
|
||||||
import { AuthMethodModel } from '../../../../core/auth/models/auth-method.model';
|
import { AuthMethodModel } from '../../../../core/auth/models/auth-method.model';
|
||||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||||
|
import { select, Store } from '@ngrx/store';
|
||||||
|
import { CoreState } from '../../../../core/core.reducers';
|
||||||
|
import { StartShibbolethAuthenticationAction } from '../../../../core/auth/auth.actions';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
import { isAuthenticated, isAuthenticationLoading } from '../../../../core/auth/selectors';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-dynamic-shibboleth',
|
selector: 'ds-dynamic-shibboleth',
|
||||||
@@ -15,7 +20,17 @@ export class DynamicShibbolethComponent implements OnInit {
|
|||||||
|
|
||||||
@Input() authMethodModel: AuthMethodModel;
|
@Input() authMethodModel: AuthMethodModel;
|
||||||
|
|
||||||
buttonHref: string;
|
/**
|
||||||
|
* True if the authentication is loading.
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
|
public loading: Observable<boolean>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether user is authenticated.
|
||||||
|
* @type {Observable<string>}
|
||||||
|
*/
|
||||||
|
public isAuthenticated: Observable<boolean> ;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The authentication form.
|
* The authentication form.
|
||||||
@@ -27,9 +42,10 @@ export class DynamicShibbolethComponent implements OnInit {
|
|||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
constructor(@Inject('authMethodModelProvider') public injectedAuthMethodModel: AuthMethodModel,
|
constructor(@Inject('authMethodModelProvider') public injectedAuthMethodModel: AuthMethodModel,
|
||||||
private formBuilder: FormBuilder) {
|
private formBuilder: FormBuilder,
|
||||||
|
private store: Store<CoreState>) {
|
||||||
this.authMethodModel = injectedAuthMethodModel;
|
this.authMethodModel = injectedAuthMethodModel;
|
||||||
this.buttonHref = ('https://fis.tiss.tuwien.ac.at' + this.authMethodModel.location + '/shibboleth')
|
// this.buttonHref = ('https://fis.tiss.tuwien.ac.at' + this.authMethodModel.location + '/shibboleth')
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
@@ -38,9 +54,17 @@ export class DynamicShibbolethComponent implements OnInit {
|
|||||||
this.shibbForm = this.formBuilder.group({
|
this.shibbForm = this.formBuilder.group({
|
||||||
shibbButton: [''],
|
shibbButton: [''],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// set isAuthenticated
|
||||||
|
this.isAuthenticated = this.store.pipe(select(isAuthenticated));
|
||||||
|
|
||||||
|
// set loading
|
||||||
|
this.loading = this.store.pipe(select(isAuthenticationLoading));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
submit() {
|
submit() {
|
||||||
console.log('submit() was callled');
|
console.log('submit() was called');
|
||||||
|
this.store.dispatch(new StartShibbolethAuthenticationAction(this.authMethodModel))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user