fix: skip onboarding on invite and signup refactoring (#2507)

Co-authored-by: Johannes <72809645+jobenjada@users.noreply.github.com>
Co-authored-by: Johannes <johannes@formbricks.com>
This commit is contained in:
Piyush Gupta
2024-04-24 19:20:04 +05:30
committed by GitHub
parent a9bf8fcdaa
commit 4f5acbcddc
3 changed files with 16 additions and 7 deletions

View File

@@ -20,17 +20,13 @@ export async function POST(request: Request) {
if (!EMAIL_AUTH_ENABLED || inviteToken ? INVITE_DISABLED : !SIGNUP_ENABLED) {
return Response.json({ error: "Signup disabled" }, { status: 403 });
}
user = { ...user, ...{ email: user.email.toLowerCase() } };
let inviteId;
try {
let invite;
let isInviteValid = false;
// create the user
user = await createUser(user);
// User is invited to team
if (inviteToken) {
let inviteTokenData = await verifyInviteToken(inviteToken);
inviteId = inviteTokenData?.inviteId;
@@ -45,7 +41,20 @@ export async function POST(request: Request) {
if (!invite) {
return Response.json({ error: "Invalid invite ID" }, { status: 400 });
}
isInviteValid = true;
}
user = {
...user,
...{ email: user.email.toLowerCase() },
onboardingCompleted: isInviteValid,
};
// create the user
user = await createUser(user);
// User is invited to team
if (isInviteValid) {
// assign user to existing team
await createMembership(invite.teamId, user.id, {
accepted: true,

View File

@@ -86,7 +86,7 @@ test.describe("Invite, accept and remove team member", async () => {
await page.getByRole("link", { name: "Create account" }).click();
await signupUsingInviteToken(page, name, email, password);
await finishOnboarding(page, false);
await page.waitForURL(/\/environments\/[^/]+\/surveys/);
});
test("Remove member", async ({ page }) => {

View File

@@ -173,7 +173,7 @@ export const SurveysList = ({
<div className="flex h-full flex-col items-center justify-center">
<span className="mb-4 h-24 w-24 rounded-full bg-slate-100 p-6 text-5xl">🕵</span>
<div className="text-slate-600">{isFetching ? "Fetching Surveys" : "No surveys found"}</div>
<div className="text-slate-600">{isFetching ? "Fetching surveys..." : "No surveys found"}</div>
</div>
)}
</div>