Skip to content

Commit

Permalink
Update pages.md (#534)
Browse files Browse the repository at this point in the history
Correct typos with getInitialProps

Co-authored-by: Iain Collins <me@iaincollins.com>
  • Loading branch information
bowen31337 and iaincollins committed Aug 6, 2020
1 parent 4fe7162 commit 07ef3d5
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions www/docs/configuration/pages.md
Expand Up @@ -27,7 +27,7 @@ To add a custom login page, for example. You can use the `pages` option:

In order to get the available authentication providers and the URLs to use for them, you can make a request to the API endpoint `/api/auth/providers`:

```jsx title="pages/auth/signin"
```jsx title="pages/auth/signin.js"
import React from 'react'
import { providers, signIn } from 'next-auth/client'

Expand All @@ -54,11 +54,11 @@ SignIn.getInitialProps = async (context) => {

If you create a custom sign in form for email sign in, you will need to submit both fields for the **email** address and **csrfToken** from **/api/auth/csrf** in a POST request to **/api/auth/signin/email**.

```jsx title="pages/auth/email-signin"
```jsx title="pages/auth/email-signin.js"
import React from 'react'
import { csrfToken } from 'next-auth/client'

export default ({ csrfToken }) => {
export default function SignIn({ csrfToken }) => {
return (
<form method='post' action='/api/auth/signin/email'>
<input name='csrfToken' type='hidden' defaultValue={csrfToken}/>
Expand All @@ -71,7 +71,7 @@ export default ({ csrfToken }) => {
)
}

export async function getInitalProps(context) {
SignIn.getInitialProps = async (context) => {
return {
csrfToken: await csrfToken(context)
}
Expand All @@ -88,11 +88,11 @@ signIn('email', { email: 'jsmith@example.com' })

If you create a sign in form for credentials based authenticaiton, you will needt to pass a **csrfToken** from **/api/auth/csrf** in a POST request to **/api/auth/callback/credentials**.

```jsx title="pages/auth/credentials-signin"
```jsx title="pages/auth/credentials-signin.js"
import React from 'react'
import { csrfToken } from 'next-auth/client'

export default ({ csrfToken }) => {
export default function SignIn({ csrfToken }) => {
return (
<form method='post' action='/api/auth/callback/credentials'>
<input name='csrfToken' type='hidden' defaultValue={csrfToken}/>
Expand All @@ -109,7 +109,7 @@ export default ({ csrfToken }) => {
)
}

export async function getInitalProps(context) {
SignIn.getInitialProps = async (context) => {
return {
csrfToken: await csrfToken(context)
}
Expand Down

1 comment on commit 07ef3d5

@vercel
Copy link

@vercel vercel bot commented on 07ef3d5 Aug 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.