Skip to content

Commit

Permalink
Fix team invite signup not working
Browse files Browse the repository at this point in the history
  • Loading branch information
hariombalhara committed Feb 16, 2024
1 parent a056160 commit 3093e71
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion packages/lib/server/username.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,9 @@ const usernameCheckForSignup = async ({
// The only way to differentiate b/w 'a new email that was invited to an Org' and 'a user that was created using regular signup' is to check if the user is a member of an org.
// If username is in global namespace
if (!userIsAMemberOfAnOrg) {
response.available = false;
const isClaimingAlreadySetUsername = user.username === username;
const isClaimingUnsetUsername = !user.username;
response.available = isClaimingUnsetUsername || isClaimingAlreadySetUsername;
// There are no premium users outside an organization only
response.premium = await isPremiumUserName(username);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,11 @@ export async function createNewUsersConnectToOrgIfExists({
const { orgId, autoAccept } = connectionInfoMap[usernameOrEmail];
const [emailUser, emailDomain] = usernameOrEmail.split("@");
const username =
emailDomain === autoAcceptEmailDomain
? slugify(emailUser)
: slugify(`${emailUser}-${emailDomain.split(".")[0]}`);
input.isOrg || parentId
? emailDomain === autoAcceptEmailDomain
? slugify(emailUser)
: slugify(`${emailUser}-${emailDomain.split(".")[0]}`)
: null;

const createdUser = await tx.user.create({
data: {
Expand Down

0 comments on commit 3093e71

Please sign in to comment.