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/standalone/videos/embed.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'client/src/standalone') diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts index fc61d3730..4ce5c78e8 100644 --- a/client/src/standalone/videos/embed.ts +++ b/client/src/standalone/videos/embed.ts @@ -5,6 +5,7 @@ import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-c import { ClientHookName, HTMLServerConfig, + OAuth2ErrorCode, PluginType, ResultList, UserRefreshToken, @@ -118,8 +119,8 @@ export class PeerTubeEmbed { if (res.status === HttpStatusCode.UNAUTHORIZED_401) return undefined return res.json() - }).then((obj: UserRefreshToken & { code: 'invalid_grant'}) => { - if (!obj || obj.code === 'invalid_grant') { + }).then((obj: UserRefreshToken & { code?: OAuth2ErrorCode }) => { + if (!obj || obj.code === OAuth2ErrorCode.INVALID_GRANT) { Tokens.flush() this.removeTokensFromHeaders() -- cgit v1.2.3