]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/shared-main/auth/auth-interceptor.service.ts
Rename not fount page to error page
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-main / auth / auth-interceptor.service.ts
index 5bcad36d01d97e2b5ab11cb877774f4ce7f7157a..e4b74f3adbd861adebb76feedb69406da7105e59 100644 (file)
@@ -1,11 +1,11 @@
 import { Observable, of, throwError as observableThrowError } from 'rxjs'
 import { catchError, switchMap } from 'rxjs/operators'
-import { HTTP_INTERCEPTORS, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, HttpErrorResponse } from '@angular/common/http'
+import { HTTP_INTERCEPTORS, HttpErrorResponse, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http'
 import { Injectable, Injector } from '@angular/core'
-import { AuthService } from '@app/core/auth/auth.service'
 import { Router } from '@angular/router'
-import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
-import { OAuth2ErrorCode, PeerTubeProblemDocument, ServerErrorCode } from '@shared/models/server'
+import { AuthService } from '@app/core/auth/auth.service'
+import { HttpStatusCode } from '@shared/models'
+import { OAuth2ErrorCode, PeerTubeProblemDocument } from '@shared/models/server'
 
 @Injectable()
 export class AuthInterceptor implements HttpInterceptor {
@@ -36,7 +36,7 @@ export class AuthInterceptor implements HttpInterceptor {
                      return this.handleNotAuthenticated(err)
                    }
 
-                   return observableThrowError(err)
+                   return observableThrowError(() => err)
                  })
                )
   }
@@ -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<any> {
-    this.router.navigateByUrl(path)
+  private handleNotAuthenticated (err: HttpErrorResponse): Observable<any> {
+    this.router.navigate([ '/401' ], { state: { obj: err }, skipLocationChange: true })
     return of(err.message)
   }
 }