]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/standalone/videos/embed.ts
Refactor server errors handler
[github/Chocobozzz/PeerTube.git] / client / src / standalone / videos / embed.ts
index fc61d37303bc4b6cc94e27fce1d52f4c7fe1068d..4ce5c78e8b45a26aae24e7055cd8aae98306bc30 100644 (file)
@@ -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()