aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/plugins/plugin-manager.ts
diff options
context:
space:
mode:
authorChocobozzz <chocobozzz@framasoft.org>2020-11-20 15:36:43 +0100
committerChocobozzz <chocobozzz@framasoft.org>2020-11-20 15:36:43 +0100
commit74fd2643b43057c25558b3da79398efe104e2660 (patch)
tree4fd7dd84775780eed82bc4b3caaa328c3526a14c /server/lib/plugins/plugin-manager.ts
parent8f3ad70874f8769f5340632754dc2ca7f4c82733 (diff)
downloadPeerTube-74fd2643b43057c25558b3da79398efe104e2660.tar.gz
PeerTube-74fd2643b43057c25558b3da79398efe104e2660.tar.zst
PeerTube-74fd2643b43057c25558b3da79398efe104e2660.zip
Provide express request to onLogout call
+ pluginInfo related changes
Diffstat (limited to 'server/lib/plugins/plugin-manager.ts')
-rw-r--r--server/lib/plugins/plugin-manager.ts12
1 files changed, 10 insertions, 2 deletions
diff --git a/server/lib/plugins/plugin-manager.ts b/server/lib/plugins/plugin-manager.ts
index 94b5ecc41..8e7491257 100644
--- a/server/lib/plugins/plugin-manager.ts
+++ b/server/lib/plugins/plugin-manager.ts
@@ -1,3 +1,4 @@
1import * as express from 'express'
1import { createReadStream, createWriteStream } from 'fs' 2import { createReadStream, createWriteStream } from 'fs'
2import { outputFile, readJSON } from 'fs-extra' 3import { outputFile, readJSON } from 'fs-extra'
3import { basename, join } from 'path' 4import { basename, join } from 'path'
@@ -166,18 +167,25 @@ export class PluginManager implements ServerHook {
166 167
167 // ###################### External events ###################### 168 // ###################### External events ######################
168 169
169 onLogout (npmName: string, authName: string, user: MUser) { 170 async onLogout (npmName: string, authName: string, user: MUser, req: express.Request) {
170 const auth = this.getAuth(npmName, authName) 171 const auth = this.getAuth(npmName, authName)
171 172
172 if (auth?.onLogout) { 173 if (auth?.onLogout) {
173 logger.info('Running onLogout function from auth %s of plugin %s', authName, npmName) 174 logger.info('Running onLogout function from auth %s of plugin %s', authName, npmName)
174 175
175 try { 176 try {
176 auth.onLogout(user) 177 // Force await, in case or onLogout returns a promise
178 const result = await auth.onLogout(user, req)
179
180 return typeof result === 'string'
181 ? result
182 : undefined
177 } catch (err) { 183 } catch (err) {
178 logger.warn('Cannot run onLogout function from auth %s of plugin %s.', authName, npmName, { err }) 184 logger.warn('Cannot run onLogout function from auth %s of plugin %s.', authName, npmName, { err })
179 } 185 }
180 } 186 }
187
188 return undefined
181 } 189 }
182 190
183 onSettingsChanged (name: string, settings: any) { 191 onSettingsChanged (name: string, settings: any) {