diff options
Diffstat (limited to 'server/lib/plugins/plugin-manager.ts')
-rw-r--r-- | server/lib/plugins/plugin-manager.ts | 12 |
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 @@ | |||
1 | import * as express from 'express' | ||
1 | import { createReadStream, createWriteStream } from 'fs' | 2 | import { createReadStream, createWriteStream } from 'fs' |
2 | import { outputFile, readJSON } from 'fs-extra' | 3 | import { outputFile, readJSON } from 'fs-extra' |
3 | import { basename, join } from 'path' | 4 | import { 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) { |