Skip to content

Commit

Permalink
Setting user authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
Swapnil-Dhamal committed Feb 24, 2025
1 parent bbace2b commit dd7e1cb
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/pages/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { useForm } from "react-hook-form";
import { Link, useNavigate } from "react-router-dom";
import logo from "../assets/Images/logo.png";
import Aos from "aos";
import { toast } from "react-toastify";
import "react-toastify/dist/ReactToastify.css";


// List of allowed email domains
const allowedDomains = [
Expand Down Expand Up @@ -38,11 +41,22 @@ export default function Login() {
return allowedDomains.includes(domain);
};

useEffect(() => {
localStorage.setItem("isAuthenticated", "false");

}, []);

console.log("Auth: ", localStorage.getItem("isAuthenticated"));

const onSubmit = (data) => {
//console.log(data);
// Perform login logic here
// If successful, navigate to admin dashboard
localStorage.setItem("userToken",data.email);
localStorage.setItem("isAuthenticated", "true");
console.log("Auth: ",localStorage.getItem("isAuthenticated"))
toast.success("Login successful!");

navigate("/admin-dashboard");
reset(); // Reset form after successful submission
};
Expand Down

0 comments on commit dd7e1cb

Please sign in to comment.