diff --git a/src/server/backend/$base/server/user.ts b/src/server/backend/$base/server/user.ts index 4367cc4a..7edcbc9d 100644 --- a/src/server/backend/$base/server/user.ts +++ b/src/server/backend/$base/server/user.ts @@ -61,7 +61,7 @@ export abstract class UserProvider extends IdTransformable { hashedPassword: string, ): Promise<[boolean, UserCompact | undefined]> - abstract getCompactById(id: Id /** , opt?: { scope: Scope } */): Promise> + abstract getCompactById(id: Id): Promise> abstract getByEmail(email: MailTokenProvider.Email, opt?: { scope: Scope }): Promise> diff --git a/src/server/backend/bancho.py/server/user.ts b/src/server/backend/bancho.py/server/user.ts index 275888be..8ff10bd2 100644 --- a/src/server/backend/bancho.py/server/user.ts +++ b/src/server/backend/bancho.py/server/user.ts @@ -139,7 +139,7 @@ class DBUserProvider extends Base implements Base { return !!res } - async getCompactById(id: Id, _opt?: { scope: Scope }) { + async getCompactById(id: Id) { const user = await this.drizzle.query.users.findFirst({ where: eq(schema.users.id, id), columns: userCompactFields, @@ -148,11 +148,11 @@ class DBUserProvider extends Base implements Base { return toUserCompact(user, this.config) } - async getByEmail(email: MailTokenProvider.Email, opt?: { scope: Scope }): Promise> { + async getByEmail(email: MailTokenProvider.Email, opt: { scope: Scope }): Promise> { return this.getCompact({ handle: email, scope: opt?.scope, keys: ['email'] }) } - async getCompact(opt: Base.OptType & { scope?: Scope }) { + async getCompact(opt: Base.OptType & { scope: Scope }) { const { handle, scope, keys = ['id', 'name', 'safeName', 'email'] } = opt let handleNum = +handle diff --git a/src/server/trpc/routers/me.ts b/src/server/trpc/routers/me.ts index eee2d00e..6da1c96b 100644 --- a/src/server/trpc/routers/me.ts +++ b/src/server/trpc/routers/me.ts @@ -162,7 +162,7 @@ export const router = _router({ ) .query(async ({ input: { target }, ctx }) => { const fromUser = ctx.user - const targetUser = await users.getCompact({ handle: target }) + const targetUser = await users.getCompact({ handle: target, scope: Scope.Self }) if (!fromUser || targetUser == null) { return diff --git a/src/server/trpc/routers/user.ts b/src/server/trpc/routers/user.ts index 89e8b8a7..401deeb5 100644 --- a/src/server/trpc/routers/user.ts +++ b/src/server/trpc/routers/user.ts @@ -189,7 +189,7 @@ export const router = _router({ }), ) .query(async ({ input }) => { - const user = await users.getCompact({ handle: input.handle }) + const user = await users.getCompact({ handle: input.handle, scope: Scope.Public }) return mapId(user, UserProvider.idToString) }), @@ -294,7 +294,7 @@ export const router = _router({ .mutation(async ({ ctx, input }) => { const variant = Mail.Variant.AccountRecovery - const user = await users.getByEmail(input as MailTokenProvider.Email) + const user = await users.getByEmail(input as MailTokenProvider.Email, { scope: Scope.Self }) const { otp, token } = await mailToken.getOrCreate(input as MailTokenProvider.Email) const t = await useTranslation(ctx.h3Event)