Skip to content

A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.

Merge branch 'dev' into ajnart/fix-duplicate-users

Meier Lukasf30f133bfa1b
diff --cc apps/nextjs/src/app/[locale]/manage/users/[userId]/_profile-form.tsx
index ae55c8a16,517bfc92c..01a3e06c7
--- a/apps/nextjs/src/app/[locale]/manage/users/[userId]/_profile-form.tsx
+++ b/apps/nextjs/src/app/[locale]/manage/users/[userId]/_profile-form.tsx
@@@ -21,25 -21,11 +21,25 @@@ interface UserProfileFormProps
export const UserProfileForm = ({ user }: UserProfileFormProps) => {
const t = useI18n();
+ const form = useForm({
+ initialValues: {
+ name: user.name ?? "",
+ email: user.email ?? "",
+ },
+ validate: zodResolver(validation.user.editProfile.omit({ id: true })),
+ validateInputOnBlur: true,
+ validateInputOnChange: true,
+ });
const { mutate, isPending } = clientApi.user.editProfile.useMutation({
async onSettled() {
- await revalidatePathAction("/manage/users");
+ await revalidatePathActionAsync("/manage/users");
},
- onSuccess() {
+ onSuccess(_, variables) {
+ // Reset form initial values to reset dirty state
+ form.setInitialValues({
+ name: variables.name,
+ email: variables.email ?? "",
+ });
showSuccessNotification({
title: t("common.notification.update.success"),
message: t("user.action.editProfile.notification.success.message"),
diff --cc packages/api/src/router/user.ts
index 0f35a0c46,70e2cbd88..f70ba6de4
--- a/packages/api/src/router/user.ts
+++ b/packages/api/src/router/user.ts
@@@ -51,19 -51,15 +51,20 @@@ export const userRouter = createTRPCRou
});
}
+ await checkUsernameAlreadyTakenAndThrowAsync(ctx.db, input.username);
+
- await createUser(ctx.db, input);
++ await createUserAsync(ctx.db, input);
+ await createUserAsync(ctx.db, input);
// Delete invite as it's used
await ctx.db.delete(invites).where(inviteWhere);
}),
create: publicProcedure
.input(validation.user.create)
.mutation(async ({ ctx, input }) => {
+ await checkUsernameAlreadyTakenAndThrowAsync(ctx.db, input.username);
+
- await createUser(ctx.db, input);
- }),
+ await createUserAsync(ctx.db, input);
- }),
++ }),
setProfileImage: protectedProcedure
.input(
z.object({
@@@ -258,11 -248,9 +259,11 @@@ const createUserAsync = async
db: Database,
input: z.infer<typeof validation.user.create>,
) => {
- const salt = await createSalt();
- const hashedPassword = await hashPassword(input.password, salt);
+ const salt = await createSaltAsync();
+ const hashedPassword = await hashPasswordAsync(input.password, salt);
+ const username = input.username.toLowerCase();
+
const userId = createId();
await db.insert(schema.users).values({
id: userId,