diff options
author | Chocobozzz <me@florianbigard.com> | 2021-03-12 17:19:02 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-03-24 18:18:41 +0100 |
commit | 97aeb3cc46c2e03c3187accd7c4561209be8be89 (patch) | |
tree | 079921eabd87bc14c2eaad42e4eda4a68a208102 /server/lib/auth/oauth-model.ts | |
parent | c2bd7a6fcff652b149b24a642314c88e56a07f48 (diff) | |
download | PeerTube-97aeb3cc46c2e03c3187accd7c4561209be8be89.tar.gz PeerTube-97aeb3cc46c2e03c3187accd7c4561209be8be89.tar.zst PeerTube-97aeb3cc46c2e03c3187accd7c4561209be8be89.zip |
Fix external on logout hook
Diffstat (limited to 'server/lib/auth/oauth-model.ts')
-rw-r--r-- | server/lib/auth/oauth-model.ts | 10 |
1 files changed, 8 insertions, 2 deletions
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 @@ | |||
1 | import * as express from 'express' | ||
1 | import { AccessDeniedError } from 'oauth2-server' | 2 | import { AccessDeniedError } from 'oauth2-server' |
2 | import { PluginManager } from '@server/lib/plugins/plugin-manager' | 3 | import { PluginManager } from '@server/lib/plugins/plugin-manager' |
3 | import { ActorModel } from '@server/models/activitypub/actor' | 4 | import { ActorModel } from '@server/models/activitypub/actor' |
@@ -125,15 +126,20 @@ async function getUser (usernameOrEmail?: string, password?: string, bypassLogin | |||
125 | 126 | ||
126 | async function revokeToken ( | 127 | async function revokeToken ( |
127 | tokenInfo: { refreshToken: string }, | 128 | tokenInfo: { refreshToken: string }, |
128 | explicitLogout?: boolean | 129 | options: { |
130 | req?: express.Request | ||
131 | explicitLogout?: boolean | ||
132 | } = {} | ||
129 | ): Promise<{ success: boolean, redirectUrl?: string }> { | 133 | ): Promise<{ success: boolean, redirectUrl?: string }> { |
134 | const { req, explicitLogout } = options | ||
135 | |||
130 | const token = await OAuthTokenModel.getByRefreshTokenAndPopulateUser(tokenInfo.refreshToken) | 136 | const token = await OAuthTokenModel.getByRefreshTokenAndPopulateUser(tokenInfo.refreshToken) |
131 | 137 | ||
132 | if (token) { | 138 | if (token) { |
133 | let redirectUrl: string | 139 | let redirectUrl: string |
134 | 140 | ||
135 | if (explicitLogout === true && token.User.pluginAuth && token.authName) { | 141 | if (explicitLogout === true && token.User.pluginAuth && token.authName) { |
136 | redirectUrl = await PluginManager.Instance.onLogout(token.User.pluginAuth, token.authName, token.User, this.request) | 142 | redirectUrl = await PluginManager.Instance.onLogout(token.User.pluginAuth, token.authName, token.User, req) |
137 | } | 143 | } |
138 | 144 | ||
139 | TokensCache.Instance.clearCacheByToken(token.accessToken) | 145 | TokensCache.Instance.clearCacheByToken(token.accessToken) |