mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
74053: redirectOn404Or401
This commit is contained in:
@@ -171,16 +171,20 @@ export const getAllSucceededRemoteListPayload = () =>
|
||||
);
|
||||
|
||||
/**
|
||||
* Operator that checks if a remote data object contains a page not found error
|
||||
* When it does contain such an error, it will redirect the user to a page not found, without altering the current URL
|
||||
* Operator that checks if a remote data object returned a 401 or 404 error
|
||||
* When it does contain such an error, it will redirect the user to the related error page, without altering the current URL
|
||||
* @param router The router used to navigate to a new page
|
||||
*/
|
||||
export const redirectToPageNotFoundOn404 = (router: Router) =>
|
||||
export const redirectOn404Or401 = (router: Router) =>
|
||||
<T>(source: Observable<RemoteData<T>>): Observable<RemoteData<T>> =>
|
||||
source.pipe(
|
||||
tap((rd: RemoteData<T>) => {
|
||||
if (rd.hasFailed && rd.error.statusCode === 404) {
|
||||
router.navigateByUrl('/404', { skipLocationChange: true });
|
||||
if (rd.hasFailed) {
|
||||
if (rd.error.statusCode === 404) {
|
||||
router.navigateByUrl('/404', {skipLocationChange: true});
|
||||
} else if (rd.error.statusCode === 401) {
|
||||
router.navigateByUrl('/401', {skipLocationChange: true});
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
|
Reference in New Issue
Block a user