Skip to content

Commit

Permalink
redirect to login after User account creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Winston-Hsiao committed Aug 10, 2024
1 parent db4d5f6 commit 8af0e57
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions frontend/src/components/auth/SignupForm.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SubmitHandler, useForm } from "react-hook-form";
import { Link } from "react-router-dom";
import { Link, useNavigate } from "react-router-dom";

import { zodResolver } from "@hookform/resolvers/zod";
import { useAlertQueue } from "hooks/useAlertQueue";
Expand All @@ -19,6 +19,7 @@ interface SignupFormProps {
const SignupForm: React.FC<SignupFormProps> = ({ signupTokenId }) => {
const auth = useAuthentication();
const { addAlert, addErrorAlert } = useAlertQueue();
const navigate = useNavigate();

const {
register,
Expand All @@ -33,8 +34,6 @@ const SignupForm: React.FC<SignupFormProps> = ({ signupTokenId }) => {
const confirmPassword = watch("confirmPassword") || "";
const passwordStrength = password.length > 0 ? zxcvbn(password).score : 0;

const { addAlert, addErrorAlert } = useAlertQueue();

const onSubmit: SubmitHandler<SignupType> = async (data: SignupType) => {
// Exit account creation early if password too weak or not matching
if (passwordStrength < 2) {
Expand All @@ -58,9 +57,8 @@ const SignupForm: React.FC<SignupFormProps> = ({ signupTokenId }) => {
addErrorAlert(error);
} else {
addAlert("Registration successful! You can now log in.", "success");

// Redirect to login page or other page
// Sign user in
navigate("/login");
// Sign user in automatically?
}
} catch (err) {
addErrorAlert(err);
Expand Down

0 comments on commit 8af0e57

Please sign in to comment.