mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 10:34:15 +00:00
Basic implmentation of the dynamic rendering of Authentication Methods
This commit is contained in:
@@ -62,17 +62,17 @@ export class AuthEffects {
|
|||||||
* Authenticate user.
|
* Authenticate user.
|
||||||
* @method authenticate
|
* @method authenticate
|
||||||
*/
|
*/
|
||||||
/* @Effect()
|
@Effect()
|
||||||
public shibbolethAuthenticate$: Observable<Action> = this.actions$.pipe(
|
public shibbolethAuthenticate$: Observable<Action> = this.actions$.pipe(
|
||||||
ofType(AuthActionTypes.START_SHIBBOLETH_AUTHENTICATION),
|
ofType(AuthActionTypes.START_SHIBBOLETH_AUTHENTICATION),
|
||||||
switchMap((action: StartShibbolethAuthenticationAction) => {
|
switchMap((action: StartShibbolethAuthenticationAction) => {
|
||||||
return this.authService.authenticate(action.payload.location).pipe(
|
return this.authService.shibbolethAuthenticate(action.payload.location).pipe(
|
||||||
take(1),
|
take(1),
|
||||||
map((response: AuthStatus) => new AuthenticationSuccessAction(response.token)),
|
map((response: AuthStatus) => new AuthenticationSuccessAction(response.token)),
|
||||||
catchError((error) => observableOf(new AuthenticationErrorAction(error)))
|
catchError((error) => observableOf(new AuthenticationErrorAction(error)))
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
);*/
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shib Login.
|
* Shib Login.
|
||||||
|
@@ -115,6 +115,19 @@ export class AuthService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shibbolethAuthenticate(location: string) {
|
||||||
|
// implement a call to the backend here
|
||||||
|
console.log('location: ', location);
|
||||||
|
return this.authRequestService.postToEndpoint('login').pipe(
|
||||||
|
map((status: AuthStatus) => {
|
||||||
|
if (status.authenticated) {
|
||||||
|
return status;
|
||||||
|
} else {
|
||||||
|
throw(new Error('Shibboleth login failed'));
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
public startShibbAuth(): Observable<AuthStatus> {
|
public startShibbAuth(): Observable<AuthStatus> {
|
||||||
console.log('startShibAuth() was called');
|
console.log('startShibAuth() was called');
|
||||||
// Attempt authenticating the user after the shibboleth/saml response reached the backend
|
// Attempt authenticating the user after the shibboleth/saml response reached the backend
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
import { AuthMethodType } from './authMethods-type';
|
import { AuthMethodType } from './authMethods-type';
|
||||||
|
|
||||||
const authMethodsMap = new Map();
|
const authMethodsMap = new Map();
|
||||||
|
|
||||||
export function renderAuthMethodFor(authMethodType: AuthMethodType) {
|
export function renderAuthMethodFor(authMethodType: AuthMethodType) {
|
||||||
return function decorator(objectElement: any) {
|
return function decorator(objectElement: any) {
|
||||||
if (!objectElement) {
|
if (!objectElement) {
|
||||||
|
@@ -1,13 +1,8 @@
|
|||||||
import { Component, ContentChild, Injector, Input, OnInit, ViewChild, ViewChildren } 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, isAuthenticated, isAuthenticationLoading } from '../../../core/auth/selectors';
|
|
||||||
import { select, Store } from '@ngrx/store';
|
import { select, Store } from '@ngrx/store';
|
||||||
import { AppState } from '../../../app.reducer';
|
|
||||||
import { Observable } from 'rxjs';
|
|
||||||
import { AuthMethodType } from '../authMethods-type';
|
|
||||||
import { CoreState } from '../../../core/core.reducers';
|
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.
|
||||||
@@ -45,9 +40,6 @@ export class LoginContainerComponent implements OnInit {
|
|||||||
],
|
],
|
||||||
parent: this.injector
|
parent: this.injector
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -57,9 +49,4 @@ export class LoginContainerComponent implements OnInit {
|
|||||||
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());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -49,7 +49,7 @@ export class DynamicShibbolethComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
console.log('injectedAuthMethodModel', this.injectedAuthMethodModel);
|
// console.log('injectedAuthMethodModel', this.injectedAuthMethodModel);
|
||||||
// set formGroup
|
// set formGroup
|
||||||
this.shibbForm = this.formBuilder.group({
|
this.shibbForm = this.formBuilder.group({
|
||||||
shibbButton: [''],
|
shibbButton: [''],
|
||||||
|
Reference in New Issue
Block a user