mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
Merge branch 'Authentication-issue-fix' into w2p-55693_Item-mapping-to-collections
This commit is contained in:
@@ -26,8 +26,9 @@ export class AuthResponseParsingService extends BaseResponseParsingService imple
|
||||
|
||||
parse(request: RestRequest, data: DSpaceRESTV2Response): RestResponse {
|
||||
if (isNotEmpty(data.payload) && isNotEmpty(data.payload._links) && (data.statusCode === '200' || data.statusCode === 'OK')) {
|
||||
const response = this.process<AuthStatus, AuthType>(data.payload, request.href);
|
||||
return new AuthStatusResponse(response[Object.keys(response)[0]][0], data.statusCode);
|
||||
const response: AuthStatus = this.process<AuthStatus, AuthType>(data.payload, request.href);
|
||||
response.eperson = data.payload._embedded.eperson;
|
||||
return new AuthStatusResponse(response, data.statusCode);
|
||||
} else {
|
||||
return new AuthStatusResponse(data.payload as AuthStatus, data.statusCode);
|
||||
}
|
||||
|
@@ -126,7 +126,7 @@ export class AuthService {
|
||||
return this.authRequestService.getRequest('status', options)
|
||||
.map((status: AuthStatus) => {
|
||||
if (status.authenticated) {
|
||||
return status.eperson[0];
|
||||
return status.eperson;
|
||||
} else {
|
||||
throw(new Error('Not authenticated'));
|
||||
}
|
||||
|
@@ -13,7 +13,7 @@ export class AuthStatus {
|
||||
|
||||
error?: AuthError;
|
||||
|
||||
eperson: Eperson[];
|
||||
eperson: Eperson;
|
||||
|
||||
token?: AuthTokenInfo;
|
||||
|
||||
|
@@ -21,6 +21,6 @@ export class NormalizedAuthStatus extends NormalizedDSpaceObject {
|
||||
authenticated: boolean;
|
||||
|
||||
@autoserializeAs(Eperson)
|
||||
eperson: Eperson[];
|
||||
eperson: Eperson;
|
||||
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ export class ServerAuthService extends AuthService {
|
||||
return this.authRequestService.getRequest('status', options)
|
||||
.map((status: AuthStatus) => {
|
||||
if (status.authenticated) {
|
||||
return status.eperson[0];
|
||||
return status.eperson;
|
||||
} else {
|
||||
throw(new Error('Not authenticated'));
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ export class AuthRequestServiceStub {
|
||||
if (this.validateToken(token)) {
|
||||
authStatusStub.authenticated = true;
|
||||
authStatusStub.token = this.mockTokenInfo;
|
||||
authStatusStub.eperson = [this.mockUser];
|
||||
authStatusStub.eperson = this.mockUser;
|
||||
} else {
|
||||
authStatusStub.authenticated = false;
|
||||
}
|
||||
@@ -45,7 +45,7 @@ export class AuthRequestServiceStub {
|
||||
if (this.validateToken(token)) {
|
||||
authStatusStub.authenticated = true;
|
||||
authStatusStub.token = this.mockTokenInfo;
|
||||
authStatusStub.eperson = [this.mockUser];
|
||||
authStatusStub.eperson = this.mockUser;
|
||||
} else {
|
||||
authStatusStub.authenticated = false;
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@ export class AuthServiceStub {
|
||||
authStatus.okay = true;
|
||||
authStatus.authenticated = true;
|
||||
authStatus.token = this.token;
|
||||
authStatus.eperson = [EpersonMock];
|
||||
authStatus.eperson = EpersonMock;
|
||||
return Observable.of(authStatus);
|
||||
} else {
|
||||
console.log('error');
|
||||
|
Reference in New Issue
Block a user