diff options
author | Chocobozzz <me@florianbigard.com> | 2021-05-05 15:26:28 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-05-05 15:26:28 +0200 |
commit | b31d72625dd32143a45277528b90bb67a881f249 (patch) | |
tree | 7721accc994121de668933672a3d51b892e3cb77 /server/lib/plugins/plugin-helpers-builder.ts | |
parent | 7a22a0a56aa75fbb1ba986a5d2c606e1343f30c2 (diff) | |
download | PeerTube-b31d72625dd32143a45277528b90bb67a881f249.tar.gz PeerTube-b31d72625dd32143a45277528b90bb67a881f249.tar.zst PeerTube-b31d72625dd32143a45277528b90bb67a881f249.zip |
Plugin user.getAuthUser is now async
So we can load the full user
Diffstat (limited to 'server/lib/plugins/plugin-helpers-builder.ts')
-rw-r--r-- | server/lib/plugins/plugin-helpers-builder.ts | 8 |
1 files changed, 7 insertions, 1 deletions
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' | |||
17 | import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist, removeServerFromBlocklist } from '../blocklist' | 17 | import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist, removeServerFromBlocklist } from '../blocklist' |
18 | import { getServerConfig } from '../config' | 18 | import { getServerConfig } from '../config' |
19 | import { blacklistVideo, unblacklistVideo } from '../video-blacklist' | 19 | import { blacklistVideo, unblacklistVideo } from '../video-blacklist' |
20 | import { UserModel } from '@server/models/account/user' | ||
20 | 21 | ||
21 | function buildPluginHelpers (pluginModel: MPlugin, npmName: string): PeerTubeHelpers { | 22 | function buildPluginHelpers (pluginModel: MPlugin, npmName: string): PeerTubeHelpers { |
22 | const logger = buildPluginLogger(npmName) | 23 | const logger = buildPluginLogger(npmName) |
@@ -163,6 +164,11 @@ function buildPluginRelatedHelpers (plugin: MPlugin, npmName: string) { | |||
163 | 164 | ||
164 | function buildUserHelpers () { | 165 | function buildUserHelpers () { |
165 | return { | 166 | return { |
166 | getAuthUser: (res: express.Response) => res.locals.oauth?.token?.User | 167 | getAuthUser: (res: express.Response) => { |
168 | const user = res.locals.oauth?.token?.User | ||
169 | if (!user) return undefined | ||
170 | |||
171 | return UserModel.loadByIdFull(user.id) | ||
172 | } | ||
167 | } | 173 | } |
168 | } | 174 | } |