Skip to content
This repository was archived by the owner on Jul 15, 2020. It is now read-only.

Commit cadc19c

Browse files
committed
Fix for email authentication and error handling
Fixing bug with email link page introduced in 4.5.0 and improving new error page formatting.
1 parent b276629 commit cadc19c

File tree

3 files changed

+17
-25
lines changed

3 files changed

+17
-25
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nextjs-starter",
3-
"version": "4.5.2",
3+
"version": "4.5.3",
44
"description": "A starter Next.js project with email and oAuth authentication",
55
"author": "Iain Collins <[email protected]>",
66
"license": "ISC",

pages/auth/check-email.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default class extends Page {
1212

1313
// If signed in already, instead of displaying message send to callback page
1414
// which should redirect them to whatever page it normally sends clients to
15-
if (session.user) {
15+
if (props.session.user) {
1616
if (req) {
1717
res.redirect('/auth/callback')
1818
} else {

pages/auth/error.js

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
import React from 'react'
2-
import Head from 'next/head'
32
import Link from 'next/link'
3+
import Page from '../../components/page'
4+
import Layout from '../../components/layout'
45

5-
export default class extends React.Component {
6+
export default class extends Page {
67

7-
static async getInitialProps({query}) {
8-
return {
9-
action: query.action || null,
10-
type: query.type || null,
11-
service: query.service || null
12-
}
8+
static async getInitialProps({req, query}) {
9+
let props = await super.getInitialProps({req})
10+
props.action = query.action || null
11+
props.type = query.type || null
12+
props.service = query.service || null
13+
return props
1314
}
1415

1516
render() {
1617
if (this.props.action == 'signin' && this.props.type == 'oauth' && this.props.service) {
1718
return(
18-
<div className="container">
19-
<Head>
20-
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossOrigin="anonymous"/>
21-
</Head>
19+
<Layout {...this.props} navmenu={false}>
2220
<div className="text-center">
2321
<h1 className="display-4 mt-5 mb-3">Unable to sign in with {this.props.service}</h1>
2422
<p className="lead">An account associated with your email address already exists.</p>
@@ -39,35 +37,29 @@ export default class extends React.Component {
3937
</div>
4038
</div>
4139
</div>
42-
</div>
40+
</Layout>
4341
)
4442
} else if (this.props.action == 'signin' && this.props.type == 'token-invalid') {
4543
return(
46-
<div className="container">
47-
<Head>
48-
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossOrigin="anonymous"/>
49-
</Head>
44+
<Layout {...this.props} navmenu={false}>
5045
<div className="text-center">
5146
<h1 className="display-4 mt-5 mb-2">Sign in link not valid</h1>
5247
<p className="lead">The sign in link you used is no longer valid.</p>
5348
<p className="lead"><Link href="/auth"><a>Get a new sign in link.</a></Link></p>
5449
</div>
55-
</div>
50+
</Layout>
5651
)
5752
} else {
5853
return(
59-
<div className="container">
60-
<Head>
61-
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossOrigin="anonymous"/>
62-
</Head>
54+
<Layout {...this.props} navmenu={false}>
6355
<div className="text-center">
6456
<h1 className="display-4 mt-5">Error signing in</h1>
6557
<p className="lead">An error occured while trying to sign in.</p>
6658
<p>
6759
<Link href="/"><a>Home</a></Link>
6860
</p>
6961
</div>
70-
</div>
62+
</Layout>
7163
)
7264
}
7365
}

0 commit comments

Comments
 (0)