import { signIn } from 'next-auth/client' import Button from 'react-bootstrap/Button' import styles from './login.module.css' import GithubIcon from '../svgs/github-fill.svg' import TwitterIcon from '../svgs/twitter-fill.svg' import LightningIcon from '../svgs/bolt.svg' import { Form, Input, SubmitButton } from '../components/form' import * as Yup from 'yup' import { useState } from 'react' import Alert from 'react-bootstrap/Alert' import LayoutCenter from '../components/layout-center' import { useRouter } from 'next/router' import { LightningAuth } from './lightning-auth' export const EmailSchema = Yup.object({ email: Yup.string().email('email is no good').required('required') }) export function EmailLoginForm ({ callbackUrl }) { return (
{ signIn('email', { email, callbackUrl }) }} > Login with Email
) } export default function Login ({ providers, callbackUrl, error, Header }) { const errors = { Signin: 'Try signing with a different account.', OAuthSignin: 'Try signing with a different account.', OAuthCallback: 'Try signing with a different account.', OAuthCreateAccount: 'Try signing with a different account.', EmailCreateAccount: 'Try signing with a different account.', Callback: 'Try signing with a different account.', OAuthAccountNotLinked: 'To confirm your identity, sign in with the same account you used originally.', EmailSignin: 'Check your email address.', CredentialsSignin: 'Lightning auth failed.', default: 'Unable to sign in.' } const [errorMessage, setErrorMessage] = useState(error && (errors[error] ?? errors.default)) const router = useRouter() return (
{Header &&
}
Not registered? Just login, we'll automatically create an account.
{errorMessage && setErrorMessage(undefined)} dismissible>{errorMessage}} {router.query.type === 'lightning' ? : ( <> {Object.values(providers).map(provider => { if (provider.name === 'Email' || provider.name === 'Lightning') { return null } const [variant, Icon] = provider.name === 'Twitter' ? ['twitter', TwitterIcon] : ['dark', GithubIcon] return ( ) })}
or
)}
) }