mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 02:24:11 +00:00
Added action to retrieve authenticated eperson object
This commit is contained in:
@@ -2,11 +2,9 @@ import { HttpHeaders } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { filter, map, switchMap, take } from 'rxjs/operators';
|
||||
import { filter, map, take } from 'rxjs/operators';
|
||||
import { isNotEmpty } from '../../shared/empty.util';
|
||||
import { followLink } from '../../shared/utils/follow-link-config.model';
|
||||
import { HttpOptions } from '../dspace-rest-v2/dspace-rest-v2.service';
|
||||
import { EPerson } from '../eperson/models/eperson.model';
|
||||
import { CheckAuthenticationTokenAction } from './auth.actions';
|
||||
import { AuthService } from './auth.service';
|
||||
import { AuthStatus } from './models/auth-status.model';
|
||||
@@ -22,7 +20,7 @@ export class ServerAuthService extends AuthService {
|
||||
* Returns the authenticated user
|
||||
* @returns {User}
|
||||
*/
|
||||
public authenticatedUser(token: AuthTokenInfo): Observable<EPerson> {
|
||||
public authenticatedUser(token: AuthTokenInfo): Observable<string> {
|
||||
// Determine if the user has an existing auth session on the server
|
||||
const options: HttpOptions = Object.create({});
|
||||
let headers = new HttpHeaders();
|
||||
@@ -35,10 +33,9 @@ export class ServerAuthService extends AuthService {
|
||||
|
||||
options.headers = headers;
|
||||
return this.authRequestService.getRequest('status', options).pipe(
|
||||
map((status) => this.linkService.resolveLinks(status, followLink<AuthStatus>('eperson'))),
|
||||
switchMap((status: AuthStatus) => {
|
||||
map((status: AuthStatus) => {
|
||||
if (status.authenticated) {
|
||||
return status.eperson.pipe(map((eperson) => eperson.payload));
|
||||
return status._links.eperson.href;
|
||||
} else {
|
||||
throw(new Error('Not authenticated'));
|
||||
}
|
||||
|
Reference in New Issue
Block a user