Skip to content

Refactor: automatically validate the email verification code #3648

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Siddharth-2382
Copy link

@Siddharth-2382 Siddharth-2382 commented May 23, 2025

Description 📣

Automatically validate the email verification code (no need to press or click the Verify button).

Fixes #1528

Type ✨

  • Bug fix
  • New feature
  • Improvement
  • Breaking change
  • Documentation

Tests 🛠️

CleanShot 2025-05-22 at 23 10 02


@maidul98
Copy link
Collaborator

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR improves the signup UX by automatically validating email verification codes as they are entered, removing the need for manual verification button clicks.

  • Removed manual verification button and related props from frontend/src/components/auth/CodeInputStep.tsx
  • Added automatic code validation in frontend/src/pages/auth/SignUpPage/SignUpPage.tsx through handleCodeChange function
  • Potential security consideration: Ensure rate limiting is in place for automatic verification attempts to prevent brute force attacks
  • Consider adding documentation in /docs to highlight this UX improvement for users
  • Recommend adding error handling for network failures during automatic validation

💡 (2/5) Greptile learns from your feedback when you react with 👍/👎!

2 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings | Greptile

@@ -79,6 +64,21 @@ export const SignUpPage = () => {
})();
}, [step]);

const handleCodeChange = async (value: string) => {
setCodeError(false);
if (value.length === 6 && step === 2 && !isCodeInputCheckLoading) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Race condition possible if user types quickly and triggers multiple validations before isCodeInputCheckLoading is reset

Comment on lines +75 to +77
} catch (err) {
setCodeError(true);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Error should be logged or handled more specifically than just setting codeError=true

Comment on lines 48 to 50
const incrementStep = async () => {
if (step === 1 || step === 3 || step === 4) {
setStep(step + 1);
} else if (step === 2) {
setIsCodeInputCheckLoading(true);
// Checking if the code matches the email.
try {
const { token } = await mutateAsync({ email, code });
SecurityClient.setSignupToken(token);
setStep(3);
} catch (err) {
console.error(err);
setCodeError(true);
}
setIsCodeInputCheckLoading(false);
}
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntax: Extra indentation on line 49 should be removed

Suggested change
const incrementStep = async () => {
if (step === 1 || step === 3 || step === 4) {
setStep(step + 1);
} else if (step === 2) {
setIsCodeInputCheckLoading(true);
// Checking if the code matches the email.
try {
const { token } = await mutateAsync({ email, code });
SecurityClient.setSignupToken(token);
setStep(3);
} catch (err) {
console.error(err);
setCodeError(true);
}
setIsCodeInputCheckLoading(false);
}
};
const incrementStep = async () => {
setStep(step + 1);
};

@AumPatel1
Copy link

/lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatically validate the email verification code (no need to press <ENTER>)
3 participants