Skip to content

Commit

Permalink
Add redirect to home from login
Browse files Browse the repository at this point in the history
  • Loading branch information
vs2961 committed Apr 8, 2024
1 parent 20928df commit 58f4db1
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions frontend/src/pages/login.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { signInWithEmailAndPassword } from "firebase/auth";
import { AlertCircle } from "lucide-react";
import Image from "next/image";
import { useRouter } from "next/navigation";
import { ReactElement, useState } from "react";
import { FieldValues, SubmitHandler, useForm } from "react-hook-form";

Expand All @@ -25,6 +26,7 @@ export default function Login() {
const _setValue = setValue;

const [firebaseError, setFirebaseError] = useState("");
const router = useRouter();

const login = async (email: string, password: string) => {
return await signInWithEmailAndPassword(auth, email, password)
Expand All @@ -41,6 +43,7 @@ export default function Login() {
login(data.email as string, data.password as string)
.then((token: string) => {
void verifyUser(token);
router.push("/home");
})
.catch((_) => {
setFirebaseError("Invalid login. Please check your username and password.");
Expand Down

0 comments on commit 58f4db1

Please sign in to comment.