mirror of
https://github.com/ajnart/homarr.git
synced 2026-02-27 08:50:56 +01:00
fix: Handle existing user when editing profile
This commit is contained in:
@@ -90,7 +90,16 @@ export const userRouter = createTRPCRouter({
|
||||
.from(users)
|
||||
.where(eq(users.id, input.userId))
|
||||
.limit(1);
|
||||
const existingUser = await ctx.db.query.users.findFirst({
|
||||
where: eq(users.name, input.form.name),
|
||||
});
|
||||
|
||||
if (existingUser !== undefined) {
|
||||
throw new TRPCError({
|
||||
code: "FORBIDDEN",
|
||||
message: `User ${input.form.name} already exists`,
|
||||
});
|
||||
}
|
||||
const emailDirty =
|
||||
input.form.email && user[0]?.email !== input.form.email;
|
||||
await ctx.db
|
||||
|
||||
Reference in New Issue
Block a user