From: Chocobozzz Date: Mon, 11 Jan 2021 12:53:08 +0000 (+0100) Subject: Retrieve user by id instead of username X-Git-Tag: v3.0.1~30 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=1acb94750408490ce89264f92a14aceeffe81c96;p=github%2FChocobozzz%2FPeerTube.git Retrieve user by id instead of username --- diff --git a/client/src/app/+admin/users/user-edit/user-edit.ts b/client/src/app/+admin/users/user-edit/user-edit.ts index 787f4b689..1613bb0d1 100644 --- a/client/src/app/+admin/users/user-edit/user-edit.ts +++ b/client/src/app/+admin/users/user-edit/user-edit.ts @@ -106,10 +106,5 @@ export abstract class UserEdit extends FormReactive implements OnInit { label: q.label, disabled: q.disabled })) - - console.log( - this.videoQuotaOptions, - this.videoQuotaDailyOptions - ) } } diff --git a/server/controllers/api/users/me.ts b/server/controllers/api/users/me.ts index b786d7f59..7ab089713 100644 --- a/server/controllers/api/users/me.ts +++ b/server/controllers/api/users/me.ts @@ -130,7 +130,7 @@ async function getUserVideoImports (req: express.Request, res: express.Response) async function getUserInformation (req: express.Request, res: express.Response) { // We did not load channels in res.locals.user - const user = await UserModel.loadForMeAPI(res.locals.oauth.token.user.username) + const user = await UserModel.loadForMeAPI(res.locals.oauth.token.user.id) return res.json(user.toMeFormattedJSON()) } diff --git a/server/models/account/user.ts b/server/models/account/user.ts index 11003645c..534898f96 100644 --- a/server/models/account/user.ts +++ b/server/models/account/user.ts @@ -564,17 +564,17 @@ export class UserModel extends Model { static loadByUsername (username: string): Promise { const query = { where: { - username: { [Op.iLike]: username } + username } } return UserModel.findOne(query) } - static loadForMeAPI (username: string): Promise { + static loadForMeAPI (id: number): Promise { const query = { where: { - username: { [Op.iLike]: username } + id } }