Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: redirect user to email verification page if not done #2241

Merged
merged 2 commits into from
Mar 21, 2024

Conversation

ShubhamPalriwala
Copy link
Contributor

What does this PR do?

Redirects user to Email Verification page where they can request a new email if they want to when they have not verified!

Fixes #2116

How should this be tested?

  • Test A
  • Test B

Checklist

Required

  • Filled out the "How to test" section in this PR
  • Read How we Code at Formbricks
  • Self-reviewed my own code
  • Commented on my code in hard-to-understand bits
  • Ran pnpm build
  • Checked for warnings, there are none
  • Removed all console.logs
  • Merged the latest changes from main onto my branch with git pull origin main
  • My changes don't cause any responsiveness issues

Appreciated

  • If a UI change was made: Added a screen recording or screenshots to this PR
  • Updated the Formbricks Docs if changes were necessary

Copy link

vercel bot commented Mar 14, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
formbricks-cloud ⬜️ Ignored (Inspect) Visit Preview Mar 20, 2024 3:12pm
formbricks-com ⬜️ Ignored (Inspect) Visit Preview Mar 20, 2024 3:12pm

@github-actions github-actions bot added the bug Something isn't working label Mar 14, 2024
Copy link
Contributor

github-actions bot commented Mar 14, 2024

Thank you for following the naming conventions for pull request titles! 🙏

Copy link
Contributor

apps/web/app/(auth)/auth/login/components/SigninForm.tsx

The onSubmit function is quite long and complex. It would be beneficial to break it down into smaller, more manageable functions. This would make the code easier to read and maintain.
Create Issue
See the diff
Checkout the fix

    const handleSignInResponse = async (data: TSigninFormState) => {
      const signInResponse = await signIn("credentials", {
        callbackUrl: searchParams?.get("callbackUrl") || "/",
        email: data.email.toLowerCase(),
        password: data.password,
        ...(totpLogin && { totpCode: data.totpCode }),
        ...(totpBackup && { backupCode: data.backupCode }),
        redirect: false,
      });

      return signInResponse;
    };

    const handleSignInError = (signInResponse: any, data: TSigninFormState) => {
      if (signInResponse?.error === "second factor required") {
        setTotpLogin(true);
        setLoggingIn(false);
        return;
      }

      if (signInResponse?.error === "Email Verification is Pending") {
        router.push(`/auth/verification-requested?email=${data.email}`);
        return;
      }

      if (signInResponse?.error) {
        setLoggingIn(false);
        setSignInError(signInResponse.error);
        return;
      }

      if (!signInResponse?.error) {
        router.push(searchParams?.get("callbackUrl") || "/");
      }
    };

    const onSubmit: SubmitHandler<TSigninFormState> = async (data) => {
      setLoggingIn(true);

      try {
        const signInResponse = await handleSignInResponse(data);
        handleSignInError(signInResponse, data);
      } catch (error) {
        const errorMessage = error.toString();
        const errorFeedback = errorMessage.includes("Invalid URL")
          ? "Too many requests, please try again after some time!"
          : error.message;
        setSignInError(errorFeedback);
      } finally {
        setLoggingIn(false);
      }
    };
git fetch origin && git checkout -b ReviewBot/Impro-mfe98x3 origin/ReviewBot/Impro-mfe98x3

@mattinannt mattinannt added this pull request to the merge queue Mar 21, 2024
Merged via the queue into main with commit 4dc5ace Mar 21, 2024
12 of 14 checks passed
@mattinannt mattinannt deleted the shubham/for-2032-solve-verification-pending-issues branch March 21, 2024 10:48
vidhikapadia2799 pushed a commit to vidhikapadia2799/formbricks that referenced this pull request Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Show an error 'Email verification is pending' when logging in
2 participants