.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)
+ return observableThrowError(() => err)
})
)
}
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)
}
}