From 97aeb3cc46c2e03c3187accd7c4561209be8be89 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 12 Mar 2021 17:19:02 +0100 Subject: Fix external on logout hook --- server/lib/auth/oauth-model.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'server/lib') diff --git a/server/lib/auth/oauth-model.ts b/server/lib/auth/oauth-model.ts index c74869ee2..b9c69eb2d 100644 --- a/server/lib/auth/oauth-model.ts +++ b/server/lib/auth/oauth-model.ts @@ -1,3 +1,4 @@ +import * as express from 'express' import { AccessDeniedError } from 'oauth2-server' import { PluginManager } from '@server/lib/plugins/plugin-manager' import { ActorModel } from '@server/models/activitypub/actor' @@ -125,15 +126,20 @@ async function getUser (usernameOrEmail?: string, password?: string, bypassLogin async function revokeToken ( tokenInfo: { refreshToken: string }, - explicitLogout?: boolean + options: { + req?: express.Request + explicitLogout?: boolean + } = {} ): Promise<{ success: boolean, redirectUrl?: string }> { + const { req, explicitLogout } = options + const token = await OAuthTokenModel.getByRefreshTokenAndPopulateUser(tokenInfo.refreshToken) if (token) { let redirectUrl: string if (explicitLogout === true && token.User.pluginAuth && token.authName) { - redirectUrl = await PluginManager.Instance.onLogout(token.User.pluginAuth, token.authName, token.User, this.request) + redirectUrl = await PluginManager.Instance.onLogout(token.User.pluginAuth, token.authName, token.User, req) } TokensCache.Instance.clearCacheByToken(token.accessToken) -- cgit v1.2.3