From 74fd2643b43057c25558b3da79398efe104e2660 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 20 Nov 2020 15:36:43 +0100 Subject: Provide express request to onLogout call + pluginInfo related changes --- server/lib/plugins/plugin-manager.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'server/lib/plugins/plugin-manager.ts') 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 @@ +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) { -- cgit v1.2.3