2017-06-30 20:18:11 +00:00
|
|
|
import React from 'react'
|
|
|
|
import Link from 'next/link'
|
|
|
|
|
|
|
|
import redirect from '../lib/redirect'
|
2017-11-02 16:56:14 +00:00
|
|
|
import checkLoggedIn from '../lib/checkLoggedIn'
|
2017-06-30 20:18:11 +00:00
|
|
|
|
2018-03-31 06:11:36 +00:00
|
|
|
import SigninBox from '../components/SigninBox'
|
|
|
|
|
2018-05-18 08:55:12 +00:00
|
|
|
export default class Signin extends React.Component {
|
|
|
|
static async getInitialProps (context) {
|
|
|
|
const { loggedInUser } = await checkLoggedIn(context.apolloClient)
|
2017-06-30 20:18:11 +00:00
|
|
|
|
|
|
|
if (loggedInUser.user) {
|
|
|
|
// Already signed in? No need to continue.
|
|
|
|
// Throw them back to the main page
|
|
|
|
redirect(context, '/')
|
|
|
|
}
|
|
|
|
|
|
|
|
return {}
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
|
|
|
return (
|
2018-05-21 10:13:56 +00:00
|
|
|
<React.Fragment>
|
2018-03-31 06:11:36 +00:00
|
|
|
{/* SigninBox handles all login logic. */}
|
2018-05-21 10:13:56 +00:00
|
|
|
<SigninBox />
|
2017-06-30 20:18:11 +00:00
|
|
|
<hr />
|
|
|
|
New? <Link prefetch href='/create-account'><a>Create account</a></Link>
|
2018-05-21 10:13:56 +00:00
|
|
|
</React.Fragment>
|
2017-06-30 20:18:11 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
};
|