mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Merge pull request #2006 from mwoodiupui/2005
Catch and report errors from non-JSON responses to authentication requests.
This commit is contained in:
@@ -196,7 +196,24 @@ export class AuthInterceptor implements HttpInterceptor {
|
||||
authStatus.token = new AuthTokenInfo(accessToken);
|
||||
} else {
|
||||
authStatus.authenticated = false;
|
||||
authStatus.error = isNotEmpty(error) ? ((typeof error === 'string') ? JSON.parse(error) : error) : null;
|
||||
if (isNotEmpty(error)) {
|
||||
if (typeof error === 'string') {
|
||||
try {
|
||||
authStatus.error = JSON.parse(error);
|
||||
} catch (e) {
|
||||
console.error('Unknown auth error "', error, '" caused ', e);
|
||||
authStatus.error = {
|
||||
error: 'Unknown',
|
||||
message: 'Unknown auth error',
|
||||
status: 500,
|
||||
timestamp: Date.now(),
|
||||
path: ''
|
||||
};
|
||||
}
|
||||
} else {
|
||||
authStatus.error = error;
|
||||
}
|
||||
}
|
||||
}
|
||||
return authStatus;
|
||||
}
|
||||
|
Reference in New Issue
Block a user