diff --git a/src/_staart/rest/auth.ts b/src/_staart/rest/auth.ts index f3f817a6e..3dda1ea48 100644 --- a/src/_staart/rest/auth.ts +++ b/src/_staart/rest/auth.ts @@ -157,23 +157,16 @@ export const register = async ( groupId = domainDetails.groupId; } catch (error) {} } - const userId = ( - await createUser({ - ...user, - ...(groupId - ? { - memberships: { - create: { - group: { - connect: { id: groupId }, - }, - role, - }, - }, - } - : {}), - }) - ).id; + const userId = (await createUser(user)).id; + if (groupId) { + await prisma.memberships.create({ + data: { + user: { connect: { id: userId } }, + group: { connect: { id: groupId } }, + role, + }, + }); + } let resendToken: string | undefined = undefined; if (email) { const newEmail = await createEmail(userId, email, !emailVerified); diff --git a/src/_staart/rest/group.ts b/src/_staart/rest/group.ts index 2710a2e34..a27f0f585 100644 --- a/src/_staart/rest/group.ts +++ b/src/_staart/rest/group.ts @@ -780,13 +780,6 @@ export const inviteMemberToGroup = async ( ? (await getUserById(userId))?.name ?? "Someone" : "Someone"; const userDetails = await getUserById(createdUserId); - await prisma.memberships.create({ - data: { - user: { connect: { id: createdUserId } }, - group: { connect: { id: groupId } }, - role, - }, - }); mail({ to: newMemberEmail, template: Templates.INVITED_TO_TEAM, diff --git a/src/_staart/services/user.service.ts b/src/_staart/services/user.service.ts index 9c8425a49..aa907d4a3 100644 --- a/src/_staart/services/user.service.ts +++ b/src/_staart/services/user.service.ts @@ -35,7 +35,7 @@ import { sendNewPassword } from "../rest/auth"; */ export const createUser = async (user: usersCreateInput) => { user.name = capitalizeFirstAndLastLetter(user.name); - user.password = user.password ? await hash(user.password, 8) : null; + user.password = user.password ? await hash(user.password, 8) : undefined; user.profilePictureUrl = user.profilePictureUrl || `https://api.adorable.io/avatars/285/${createHash("md5")