aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app
diff options
context:
space:
mode:
authorkontrollanten <6680299+kontrollanten@users.noreply.github.com>2022-07-04 22:04:55 +0200
committerChocobozzz <me@florianbigard.com>2022-07-08 10:58:04 +0200
commit9469783d432d9d53eafe5ec0c0b4baa78af2510d (patch)
tree9c25ce85ed88b3ca0ae3373f66d36ec2cb6d24bc /client/src/app
parenta28b0f696c1990a3e7a7385e65d8ea910f46be1e (diff)
downloadPeerTube-9469783d432d9d53eafe5ec0c0b4baa78af2510d.tar.gz
PeerTube-9469783d432d9d53eafe5ec0c0b4baa78af2510d.tar.zst
PeerTube-9469783d432d9d53eafe5ec0c0b4baa78af2510d.zip
feat: custom msg upon 401 response
closes #4768
Diffstat (limited to 'client/src/app')
-rw-r--r--client/src/app/+page-not-found/page-not-found.component.html17
-rw-r--r--client/src/app/core/routing/redirect.service.ts2
-rw-r--r--client/src/app/shared/shared-main/auth/auth-interceptor.service.ts4
3 files changed, 20 insertions, 3 deletions
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 @@
1<div class="root"> 1<div class="root">
2 <div *ngIf="status !== 403 && status !== 418" class="box"> 2 <div *ngIf="status !== 401 && status !== 403 && status !== 418" class="box">
3 <strong>{{ status }}.</strong> 3 <strong>{{ status }}.</strong>
4 <span class="ms-1 muted" i18n>That's an error.</span> 4 <span class="ms-1 muted" i18n>That's an error.</span>
5 5
@@ -22,6 +22,21 @@
22 </div> 22 </div>
23 </div> 23 </div>
24 24
25 <div *ngIf="status === 401" class="box">
26 <strong>{{ status }}.</strong>
27 <span class="ms-1 muted" i18n>You are not authorized here.</span>
28
29 <div class="text mt-4">
30 <ng-container *ngIf="type === 'video'" i18n>You might need to login to see the video.</ng-container>
31 <ng-container *ngIf="type !== 'video'" i18n>You might need to login to see the resource.</ng-container>
32 </div>
33
34 <a class="peertube-button-link orange-button mt-5" i18n routerLink="/login">
35 Login
36 </a>
37
38 </div>
39
25 <div *ngIf="status === 403" class="box"> 40 <div *ngIf="status === 403" class="box">
26 <strong>{{ status }}.</strong> 41 <strong>{{ status }}.</strong>
27 <span class="ms-1 muted" i18n>You are not authorized here.</span> 42 <span class="ms-1 muted" i18n>You are not authorized here.</span>
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 {
46 this.currentUrl = this.router.url 46 this.currentUrl = this.router.url
47 router.events.subscribe(event => { 47 router.events.subscribe(event => {
48 if (event instanceof NavigationEnd || event instanceof NavigationCancel) { 48 if (event instanceof NavigationEnd || event instanceof NavigationCancel) {
49 if (event.url === '/404') return
50
49 this.previousUrl = this.currentUrl 51 this.previousUrl = this.currentUrl
50 this.currentUrl = event.url 52 this.currentUrl = event.url
51 53
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 {
61 return req.clone({ headers: req.headers.set('Authorization', authHeaderValue) }) 61 return req.clone({ headers: req.headers.set('Authorization', authHeaderValue) })
62 } 62 }
63 63
64 private handleNotAuthenticated (err: HttpErrorResponse, path = '/login'): Observable<any> { 64 private handleNotAuthenticated (err: HttpErrorResponse): Observable<any> {
65 this.router.navigateByUrl(path) 65 this.router.navigate([ '/404' ], { state: { obj: err }, skipLocationChange: true })
66 return of(err.message) 66 return of(err.message)
67 } 67 }
68} 68}