Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pages.md #534

Merged
merged 2 commits into from
Aug 6, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions www/docs/configuration/pages.md
Original file line number Diff line number Diff line change
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