import { faLeftLong } from "@fortawesome/pro-solid-svg-icons" import { FontAwesomeIcon } from "@fortawesome/react-fontawesome" import { signIn, useSession } from "next-auth/react" import { useRouter } from "next/router" import { useEffect, useState } from "react" import { toast } from "react-toastify" type SignInErrorTypes = | "Signin" | "OAuthSignin" | "OAuthCallback" | "OAuthCreateAccount" | "EmailCreateAccount" | "Callback" | "OAuthAccountNotLinked" | "EmailSignin" | "CredentialsSignin" | "SessionRequired" | "default" const errors: Record = { Signin: "Try signing in with a different account.", OAuthSignin: "Try signing in with a different account.", OAuthCallback: "Try signing in with a different account.", OAuthCreateAccount: "Try signing in with a different account.", EmailCreateAccount: "Try signing in with a different account.", Callback: "Try signing in with a different account.", OAuthAccountNotLinked: "To confirm your identity, sign in with the same account you used originally.", EmailSignin: "The e-mail could not be sent.", CredentialsSignin: "Sign in failed. Check the details you provided are correct.", SessionRequired: "Please sign in to access this page.", default: "Unable to sign in.", } function Login() { const [email, setEmail] = useState("") const { status } = useSession() const router = useRouter() const errorType = router.query.error as SignInErrorTypes useEffect(() => { if (!errorType) return toast.error(errors[errorType] ?? errors.default, { theme: "colored" }) }, [errorType]) useEffect(() => { if (status === "authenticated") router.push("/") }, [router, status]) function login(provider: "email" | "azure-ad") { return () => { signIn(provider, { email, callbackUrl: "/" }) } } return (
Avatar

Leaky Ships

Choose Login Method
{errorType &&
}
setEmail(e.target.value)} />

or
Gewerbliche Berufsbildende Schulen
{errorType &&
} {errorType && (
)}
) } export default Login