From f43db2f46ee50bacb402a6ef42d768694c2bc9a8 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 12 Mar 2021 15:20:46 +0100 Subject: Refactor auth flow Reimplement some node-oauth2-server methods to remove hacky code needed by our external login workflow --- shared/extra-utils/miscs/sql.ts | 9 +++++++++ shared/extra-utils/server/servers.ts | 1 + 2 files changed, 10 insertions(+) (limited to 'shared/extra-utils') diff --git a/shared/extra-utils/miscs/sql.ts b/shared/extra-utils/miscs/sql.ts index 345e5bc16..35e493456 100644 --- a/shared/extra-utils/miscs/sql.ts +++ b/shared/extra-utils/miscs/sql.ts @@ -130,6 +130,14 @@ function setActorFollowScores (internalServerNumber: number, newScore: number) { return seq.query(`UPDATE "actorFollow" SET "score" = ${newScore}`, options) } +function setTokenField (internalServerNumber: number, accessToken: string, field: string, value: string) { + const seq = getSequelize(internalServerNumber) + + const options = { type: QueryTypes.UPDATE } + + return seq.query(`UPDATE "oAuthToken" SET "${field}" = '${value}' WHERE "accessToken" = '${accessToken}'`, options) +} + export { setVideoField, setPlaylistField, @@ -139,6 +147,7 @@ export { setPluginLatestVersion, selectQuery, deleteAll, + setTokenField, updateQuery, setActorFollowScores, closeAllSequelize, diff --git a/shared/extra-utils/server/servers.ts b/shared/extra-utils/server/servers.ts index 08d05ef36..779a3cc36 100644 --- a/shared/extra-utils/server/servers.ts +++ b/shared/extra-utils/server/servers.ts @@ -37,6 +37,7 @@ interface ServerInfo { customConfigFile?: string accessToken?: string + refreshToken?: string videoChannel?: VideoChannel video?: { -- cgit v1.2.3