aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/oauth-model.ts
diff options
context:
space:
mode:
authorChocobozzz <chocobozzz@framasoft.org>2020-11-20 15:36:44 +0100
committerChocobozzz <chocobozzz@framasoft.org>2020-11-20 15:36:44 +0100
commitdb7510d6320f9f09a5efefe0a0b2cdcd0d6c5eec (patch)
tree4fd7dd84775780eed82bc4b3caaa328c3526a14c /server/lib/oauth-model.ts
parent8f3ad70874f8769f5340632754dc2ca7f4c82733 (diff)
parent74fd2643b43057c25558b3da79398efe104e2660 (diff)
downloadPeerTube-db7510d6320f9f09a5efefe0a0b2cdcd0d6c5eec.tar.gz
PeerTube-db7510d6320f9f09a5efefe0a0b2cdcd0d6c5eec.tar.zst
PeerTube-db7510d6320f9f09a5efefe0a0b2cdcd0d6c5eec.zip
Merge branch 'artonge/PeerTube-feature/logoutUrlForAuthProviders' into 'develop'
Artonge/peer tube feature/logout url for auth providers See merge request framasoft/peertube/PeerTube!33
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) {