From 9469783d432d9d53eafe5ec0c0b4baa78af2510d Mon Sep 17 00:00:00 2001 From: kontrollanten <6680299+kontrollanten@users.noreply.github.com> Date: Mon, 4 Jul 2022 22:04:55 +0200 Subject: feat: custom msg upon 401 response closes #4768 --- .../app/+page-not-found/page-not-found.component.html | 17 ++++++++++++++++- client/src/app/core/routing/redirect.service.ts | 2 ++ .../shared/shared-main/auth/auth-interceptor.service.ts | 4 ++-- 3 files changed, 20 insertions(+), 3 deletions(-) (limited to 'client/src/app') diff --git a/client/src/app/+page-not-found/page-not-found.component.html b/client/src/app/+page-not-found/page-not-found.component.html index 70ede26e8..c6ca8670e 100644 --- a/client/src/app/+page-not-found/page-not-found.component.html +++ b/client/src/app/+page-not-found/page-not-found.component.html @@ -1,5 +1,5 @@
-
+
{{ status }}. That's an error. @@ -22,6 +22,21 @@
+
+ {{ status }}. + You are not authorized here. + +
+ You might need to login to see the video. + You might need to login to see the resource. +
+ + + Login + + +
+
{{ status }}. You are not authorized here. diff --git a/client/src/app/core/routing/redirect.service.ts b/client/src/app/core/routing/redirect.service.ts index 2b8cbaa59..db4b35018 100644 --- a/client/src/app/core/routing/redirect.service.ts +++ b/client/src/app/core/routing/redirect.service.ts @@ -46,6 +46,8 @@ export class RedirectService { this.currentUrl = this.router.url router.events.subscribe(event => { if (event instanceof NavigationEnd || event instanceof NavigationCancel) { + if (event.url === '/404') return + this.previousUrl = this.currentUrl this.currentUrl = event.url diff --git a/client/src/app/shared/shared-main/auth/auth-interceptor.service.ts b/client/src/app/shared/shared-main/auth/auth-interceptor.service.ts index 51248c7b2..7daf31a98 100644 --- a/client/src/app/shared/shared-main/auth/auth-interceptor.service.ts +++ b/client/src/app/shared/shared-main/auth/auth-interceptor.service.ts @@ -61,8 +61,8 @@ export class AuthInterceptor implements HttpInterceptor { return req.clone({ headers: req.headers.set('Authorization', authHeaderValue) }) } - private handleNotAuthenticated (err: HttpErrorResponse, path = '/login'): Observable { - this.router.navigateByUrl(path) + private handleNotAuthenticated (err: HttpErrorResponse): Observable { + this.router.navigate([ '/404' ], { state: { obj: err }, skipLocationChange: true }) return of(err.message) } } -- cgit v1.2.3