From e030bfb59dd5ee65f20a64686ec9b22ca39f70ae Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 2 Jun 2021 18:15:41 +0200 Subject: Refactor server errors handler --- client/src/app/shared/shared-main/auth/auth-interceptor.service.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'client/src/app/shared/shared-main') 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 4fe3b964d..5bcad36d0 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 @@ -5,6 +5,7 @@ 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' @Injectable() export class AuthInterceptor implements HttpInterceptor { @@ -25,7 +26,9 @@ export class AuthInterceptor implements HttpInterceptor { return next.handle(authReq) .pipe( catchError((err: HttpErrorResponse) => { - if (err.status === HttpStatusCode.UNAUTHORIZED_401 && err.error && err.error.code === 'invalid_token') { + const error = err.error as PeerTubeProblemDocument + + if (err.status === HttpStatusCode.UNAUTHORIZED_401 && error && error.code === OAuth2ErrorCode.INVALID_TOKEN) { return this.handleTokenExpired(req, next) } -- cgit v1.2.3