aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/oauth-model.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/oauth-model.ts')
-rw-r--r--server/lib/oauth-model.ts10
1 files changed, 6 insertions, 4 deletions
diff --git a/server/lib/oauth-model.ts b/server/lib/oauth-model.ts
index 3273c6c2d..f7ea98b41 100644
--- a/server/lib/oauth-model.ts
+++ b/server/lib/oauth-model.ts
@@ -141,13 +141,15 @@ async function getUser (usernameOrEmail?: string, password?: string) {
141 return user 141 return user
142} 142}
143 143
144async function revokeToken (tokenInfo: { refreshToken: string }) { 144async function revokeToken (tokenInfo: { refreshToken: string }): Promise<{ success: boolean, redirectUrl?: string }> {
145 const res: express.Response = this.request.res 145 const res: express.Response = this.request.res
146 const token = await OAuthTokenModel.getByRefreshTokenAndPopulateUser(tokenInfo.refreshToken) 146 const token = await OAuthTokenModel.getByRefreshTokenAndPopulateUser(tokenInfo.refreshToken)
147 147
148 if (token) { 148 if (token) {
149 let redirectUrl: string
150
149 if (res.locals.explicitLogout === true && token.User.pluginAuth && token.authName) { 151 if (res.locals.explicitLogout === true && token.User.pluginAuth && token.authName) {
150 PluginManager.Instance.onLogout(token.User.pluginAuth, token.authName, token.User) 152 redirectUrl = await PluginManager.Instance.onLogout(token.User.pluginAuth, token.authName, token.User, this.request)
151 } 153 }
152 154
153 clearCacheByToken(token.accessToken) 155 clearCacheByToken(token.accessToken)
@@ -155,10 +157,10 @@ async function revokeToken (tokenInfo: { refreshToken: string }) {
155 token.destroy() 157 token.destroy()
156 .catch(err => logger.error('Cannot destroy token when revoking token.', { err })) 158 .catch(err => logger.error('Cannot destroy token when revoking token.', { err }))
157 159
158 return true 160 return { success: true, redirectUrl }
159 } 161 }
160 162
161 return false 163 return { success: false }
162} 164}
163 165
164async function saveToken (token: TokenInfo, client: OAuthClientModel, user: UserModel) { 166async function saveToken (token: TokenInfo, client: OAuthClientModel, user: UserModel) {