1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-03 17:59:37 +02:00

Plugin user.getAuthUser is now async

So we can load the full user
This commit is contained in:
Chocobozzz 2021-05-05 15:26:28 +02:00
parent 7a22a0a56a
commit b31d72625d
No known key found for this signature in database
GPG key ID: 583A612D890159BE
6 changed files with 19 additions and 7 deletions

View file

@ -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)
}
}
}