41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
import React from 'react'
|
|
import Router from 'next/router'
|
|
|
|
import Layout from '../../components/MyLayout'
|
|
import { NextAuth } from 'next-auth/client'
|
|
|
|
export default class extends React.Component {
|
|
|
|
static async getInitialProps({req, res, query}) {
|
|
let props = {};
|
|
props.session = await NextAuth.init({force: true, req: req})
|
|
|
|
// If signed in already, instead of displaying message send to callback page
|
|
// which should redirect them to whatever page it normally sends clients to
|
|
if (props.session.user) {
|
|
if (req) {
|
|
res.redirect('/auth/callback')
|
|
} else {
|
|
Router.push('/auth/callback')
|
|
}
|
|
}
|
|
|
|
props.email = query.email
|
|
|
|
return props
|
|
}
|
|
|
|
render() {
|
|
return (
|
|
<Layout menu={this.props.menu}>
|
|
<div className="text-center pt-5 pb-5">
|
|
<h1 className="display-4">Check your email</h1>
|
|
<p className="lead">
|
|
A sign in link has been sent to { (this.props.email) ? <span className="font-weight-bold">{this.props.email}</span> : <span>your inbox</span> }.
|
|
</p>
|
|
</div>
|
|
</Layout>
|
|
)
|
|
}
|
|
}
|