file based auth
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import type { Handler } from 'hono';
|
||||
import { officerdb, eq, Users } from 'officerdb';
|
||||
import { updateUser } from 'officerdb';
|
||||
import * as errors from '@@/custom-errors';
|
||||
|
||||
export const updateUserHandler: Handler = async function (ctx) {
|
||||
@@ -8,10 +8,11 @@ export const updateUserHandler: Handler = async function (ctx) {
|
||||
|
||||
if (typeof name !== 'string') throw errors.BAD_REQUEST('Name is required');
|
||||
|
||||
await officerdb
|
||||
.update(Users)
|
||||
.set({ name, username: typeof username === 'string' ? username : undefined, avatar: avatar ?? null })
|
||||
.where(eq(Users.id, reqUser.id));
|
||||
await updateUser(reqUser.id, {
|
||||
name,
|
||||
username: typeof username === 'string' ? username : undefined,
|
||||
avatar: avatar ?? null,
|
||||
});
|
||||
|
||||
return ctx.json({ ok: true });
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user