mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 02:09:37 +02:00
Provide express request to onLogout call
+ pluginInfo related changes
This commit is contained in:
parent
8f3ad70874
commit
74fd2643b4
8 changed files with 129 additions and 15 deletions
|
@ -141,13 +141,15 @@ async function getUser (usernameOrEmail?: string, password?: string) {
|
|||
return user
|
||||
}
|
||||
|
||||
async function revokeToken (tokenInfo: { refreshToken: string }) {
|
||||
async function revokeToken (tokenInfo: { refreshToken: string }): Promise<{ success: boolean, redirectUrl?: string }> {
|
||||
const res: express.Response = this.request.res
|
||||
const token = await OAuthTokenModel.getByRefreshTokenAndPopulateUser(tokenInfo.refreshToken)
|
||||
|
||||
if (token) {
|
||||
let redirectUrl: string
|
||||
|
||||
if (res.locals.explicitLogout === true && token.User.pluginAuth && token.authName) {
|
||||
PluginManager.Instance.onLogout(token.User.pluginAuth, token.authName, token.User)
|
||||
redirectUrl = await PluginManager.Instance.onLogout(token.User.pluginAuth, token.authName, token.User, this.request)
|
||||
}
|
||||
|
||||
clearCacheByToken(token.accessToken)
|
||||
|
@ -155,10 +157,10 @@ async function revokeToken (tokenInfo: { refreshToken: string }) {
|
|||
token.destroy()
|
||||
.catch(err => logger.error('Cannot destroy token when revoking token.', { err }))
|
||||
|
||||
return true
|
||||
return { success: true, redirectUrl }
|
||||
}
|
||||
|
||||
return false
|
||||
return { success: false }
|
||||
}
|
||||
|
||||
async function saveToken (token: TokenInfo, client: OAuthClientModel, user: UserModel) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue