1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 18:29:27 +02:00

Provide express request to onLogout call

+ pluginInfo related changes
This commit is contained in:
Chocobozzz 2020-11-20 15:36:43 +01:00
parent 8f3ad70874
commit 74fd2643b4
8 changed files with 129 additions and 15 deletions

View file

@ -1,3 +1,4 @@
import * as express from 'express'
import { createReadStream, createWriteStream } from 'fs'
import { outputFile, readJSON } from 'fs-extra'
import { basename, join } from 'path'
@ -166,18 +167,25 @@ export class PluginManager implements ServerHook {
// ###################### External events ######################
onLogout (npmName: string, authName: string, user: MUser) {
async onLogout (npmName: string, authName: string, user: MUser, req: express.Request) {
const auth = this.getAuth(npmName, authName)
if (auth?.onLogout) {
logger.info('Running onLogout function from auth %s of plugin %s', authName, npmName)
try {
auth.onLogout(user)
// Force await, in case or onLogout returns a promise
const result = await auth.onLogout(user, req)
return typeof result === 'string'
? result
: undefined
} catch (err) {
logger.warn('Cannot run onLogout function from auth %s of plugin %s.', authName, npmName, { err })
}
}
return undefined
}
onSettingsChanged (name: string, settings: any) {