aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/auth/oauth-model.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-03-12 17:19:02 +0100
committerChocobozzz <me@florianbigard.com>2021-03-24 18:18:41 +0100
commit97aeb3cc46c2e03c3187accd7c4561209be8be89 (patch)
tree079921eabd87bc14c2eaad42e4eda4a68a208102 /server/lib/auth/oauth-model.ts
parentc2bd7a6fcff652b149b24a642314c88e56a07f48 (diff)
downloadPeerTube-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.ts10
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 @@
1import * as express from 'express'
1import { AccessDeniedError } from 'oauth2-server' 2import { AccessDeniedError } from 'oauth2-server'
2import { PluginManager } from '@server/lib/plugins/plugin-manager' 3import { PluginManager } from '@server/lib/plugins/plugin-manager'
3import { ActorModel } from '@server/models/activitypub/actor' 4import { ActorModel } from '@server/models/activitypub/actor'
@@ -125,15 +126,20 @@ async function getUser (usernameOrEmail?: string, password?: string, bypassLogin
125 126
126async function revokeToken ( 127async 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)