]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/shared-main/auth/auth-interceptor.service.ts
Fix lint
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-main / auth / auth-interceptor.service.ts
index 7daf31a981c1092ad51788f9478574f8fe602f7d..93b3a93d6d4255def5a42c0f606353c05fb98f96 100644 (file)
@@ -27,13 +27,16 @@ export class AuthInterceptor implements HttpInterceptor {
                .pipe(
                  catchError((err: HttpErrorResponse) => {
                    const error = err.error as PeerTubeProblemDocument
+                   const isOTPMissingError = this.authService.isOTPMissingError(err)
 
-                   if (err.status === HttpStatusCode.UNAUTHORIZED_401 && error && error.code === OAuth2ErrorCode.INVALID_TOKEN) {
-                     return this.handleTokenExpired(req, next)
-                   }
+                   if (!isOTPMissingError) {
+                     if (err.status === HttpStatusCode.UNAUTHORIZED_401 && error && error.code === OAuth2ErrorCode.INVALID_TOKEN) {
+                       return this.handleTokenExpired(req, next)
+                     }
 
-                   if (err.status === HttpStatusCode.UNAUTHORIZED_401) {
-                     return this.handleNotAuthenticated(err)
+                     if (err.status === HttpStatusCode.UNAUTHORIZED_401) {
+                       return this.handleNotAuthenticated(err)
+                     }
                    }
 
                    return observableThrowError(() => err)
@@ -62,7 +65,7 @@ export class AuthInterceptor implements HttpInterceptor {
   }
 
   private handleNotAuthenticated (err: HttpErrorResponse): Observable<any> {
-    this.router.navigate([ '/404' ], { state: { obj: err }, skipLocationChange: true })
+    this.router.navigate([ '/401' ], { state: { obj: err }, skipLocationChange: true })
     return of(err.message)
   }
 }