From b31d72625dd32143a45277528b90bb67a881f249 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 5 May 2021 15:26:28 +0200 Subject: Plugin user.getAuthUser is now async So we can load the full user --- server/lib/plugins/plugin-helpers-builder.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'server/lib/plugins') diff --git a/server/lib/plugins/plugin-helpers-builder.ts b/server/lib/plugins/plugin-helpers-builder.ts index d57c69ef0..f1bc24d8b 100644 --- a/server/lib/plugins/plugin-helpers-builder.ts +++ b/server/lib/plugins/plugin-helpers-builder.ts @@ -17,6 +17,7 @@ import { VideoBlacklistCreate } from '@shared/models' import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist, removeServerFromBlocklist } from '../blocklist' import { getServerConfig } from '../config' import { blacklistVideo, unblacklistVideo } from '../video-blacklist' +import { UserModel } from '@server/models/account/user' function buildPluginHelpers (pluginModel: MPlugin, npmName: string): PeerTubeHelpers { const logger = buildPluginLogger(npmName) @@ -163,6 +164,11 @@ function buildPluginRelatedHelpers (plugin: MPlugin, npmName: string) { function buildUserHelpers () { return { - getAuthUser: (res: express.Response) => res.locals.oauth?.token?.User + getAuthUser: (res: express.Response) => { + const user = res.locals.oauth?.token?.User + if (!user) return undefined + + return UserModel.loadByIdFull(user.id) + } } } -- cgit v1.2.3