|
|
@ -9,8 +9,15 @@ import useAccountRedirect from '~/hooks/useAccountRedirect'
|
|
|
|
export default function Login(){
|
|
|
|
export default function Login(){
|
|
|
|
useAccountRedirect()
|
|
|
|
useAccountRedirect()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const redirectAfterLogin = user => {
|
|
|
|
|
|
|
|
if (user.is_admin)
|
|
|
|
|
|
|
|
Router.push('/admin')
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
Router.push('/account')
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<FormController url="/api/auth" afterSubmit={()=>Router.push('/account')}>
|
|
|
|
<FormController url="/api/auth" afterSubmit={redirectAfterLogin}>
|
|
|
|
<h1>Login</h1>
|
|
|
|
<h1>Login</h1>
|
|
|
|
<Input label="Email" type="text" name="email" validate={value=>isEmail(value)} hint="Enter a valid email address" />
|
|
|
|
<Input label="Email" type="text" name="email" validate={value=>isEmail(value)} hint="Enter a valid email address" />
|
|
|
|
<Input label="Password" type="password" name="password" validate={value=>(value.length >= 8)} hint="Password must be at least 8 characters long" />
|
|
|
|
<Input label="Password" type="password" name="password" validate={value=>(value.length >= 8)} hint="Password must be at least 8 characters long" />
|
|
|
|