Skip to content

Commit

Permalink
v1.1.6
Browse files Browse the repository at this point in the history
if user already loged in ,replace to homepage
  • Loading branch information
Jonchao committed Mar 21, 2024
1 parent 687c063 commit d6428b3
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pages/login.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { Button, Input } from "@nextui-org/react";
import Link from "next/link";
import { useState, useMemo } from "react";
import { useState, useMemo, useEffect } from "react";
import Oauth2 from "@/components/auth/Oauth2";
import { useRouter } from "next/router";
import { EyeFilledIcon, EyeSlashFilledIcon } from "@/icons";
import { login } from "@/utils/firebaseAuth";
import useAuthStatus from "@/hooks/useAuthStatus";

export default function Login() {
const router = useRouter();

const { loading, user } = useAuthStatus();
//email validate
const [email, setEmail] = useState("");
const validateEmail = (email) => email.match(/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/);
Expand Down Expand Up @@ -39,6 +40,12 @@ export default function Login() {
}
};

useEffect(() => {
if (user) {
router.replace("/");
}
});

return (
<div className="h-dvh w-dvw">
<div className="flex items-center justify-center h-2/3">
Expand Down

0 comments on commit d6428b3

Please sign in to comment.