import React, { useState, useEffect } from "react"; import { useRouter } from "next/router"; import Head from "next/head"; import Image from "next/image"; import Link from "next/link"; import InputField from "../components/basic/InputField"; import Error from "../components/basic/Error"; import Button from "../components/basic/buttons/Button"; import getWorkspaces from "./api/workspace/getWorkspaces"; import attemptLogin from "../components/utilities/attemptLogin"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faWarning } from "@fortawesome/free-solid-svg-icons"; export default function Login() { const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [errorLogin, setErrorLogin] = useState(false); const [isLoading, setIsLoading] = useState(false); const router = useRouter(); useEffect(async () => { let userWorkspace; try { const userWorkspaces = await getWorkspaces(); userWorkspace = userWorkspaces[0]._id; router.push("/dashboard/" + userWorkspace); } catch (error) { console.log("Error - Not logged in yet"); } }, []); /** * This function check if the user entered the correct credentials and should be allowed to log in. */ const loginCheck = async () => { setIsLoading(true); await attemptLogin(email, password, setErrorLogin, router, false, true).then( () => { setTimeout(function () { setIsLoading(false); }, 2000); } ); }; return (
Login
long logo

Log In

Need an Infisical account?

{errorLogin && ( )}
{/*

I may have forgotten my password.

*/}
{false &&
We are experiencing minor technical difficulties. We are working on solving it right now. Please come back in a few minutes.
}
); }