Skip to content

Commit

Permalink
fix: signup redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
ThEditor committed Sep 17, 2024
1 parent 81054c1 commit 5f49ae5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
13 changes: 13 additions & 0 deletions src/components/signin/signin-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const SignInForm = ({ className }: SignInFormProps) => {
password: "",
});
const [submitting, setSubmitting] = useState(false);
const [justRegistered, setJustRegistered] = useState(false);
const { toast } = useToast();

useEffect(() => {
Expand All @@ -33,6 +34,12 @@ const SignInForm = ({ className }: SignInFormProps) => {
duration: 5000,
});
}

const urlParams = new URLSearchParams(window.location.search);
const reg = urlParams.get("reg");
if (reg === "true") {
setJustRegistered(true);
}
}, [toast]);

// Handler for input changes
Expand Down Expand Up @@ -81,6 +88,12 @@ const SignInForm = ({ className }: SignInFormProps) => {
className,
)}
>
{/* Just Registered Toast */}
{justRegistered && (
<Text className="text-sm" variant="white">
You have successfully registered. Please sign in.
</Text>
)}
{/* Sign In Header */}
<Text className="text-4xl font-bold" variant="primary" glow="primary">
SIGN IN
Expand Down
8 changes: 6 additions & 2 deletions src/components/signup/signup-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,19 @@ const SignUpForm = ({ className }: SignUpFormProps) => {
duration: 5000,
});
setSubmitting(false);
return { data: { access_token: "" } };
return { data: { access_token: "", msg_code: -1 } };
})
).data as { access_token: string };
).data as { access_token: string, msg_code: number };
setSubmitting(false);

if (res.access_token) {
window.localStorage.setItem("token", res.access_token);
window.location.href = "/signup";
}

if (res.msg_code === 13) {
window.location.href = "/signin?reg=true";
}
};

const handleAdd = () => {
Expand Down

0 comments on commit 5f49ae5

Please sign in to comment.