feat: add permission section to create user page (#1524)

* feat: add permission section to create user page

* fix: deepsource issues
This commit is contained in:
Meier Lukas
2024-11-23 17:18:29 +01:00
committed by GitHub
parent 8fea983c2e
commit 1fc48f9db0
7 changed files with 232 additions and 32 deletions

View File

@@ -78,7 +78,11 @@ export const userRouter = createTRPCRouter({
throwIfCredentialsDisabled();
await checkUsernameAlreadyTakenAndThrowAsync(ctx.db, "credentials", input.username);
await createUserAsync(ctx.db, input);
const userId = await createUserAsync(ctx.db, input);
if (input.groupIds.length >= 1) {
await ctx.db.insert(groupMembers).values(input.groupIds.map((groupId) => ({ groupId, userId })));
}
}),
setProfileImage: protectedProcedure
.input(
@@ -459,7 +463,7 @@ export const userRouter = createTRPCRouter({
}),
});
const createUserAsync = async (db: Database, input: z.infer<typeof validation.user.create>) => {
const createUserAsync = async (db: Database, input: z.infer<typeof validation.user.baseCreate>) => {
const salt = await createSaltAsync();
const hashedPassword = await hashPasswordAsync(input.password, salt);