Compare commits

...

9 Commits

Author SHA1 Message Date
Ashutosh Kumar
fb04ab4e76 fix(ts): make GetSessionOptions optional (#1851) 2021-04-25 15:39:19 +02:00
Ashutosh Kumar
07e2a83ccb fix(ts): make ctxOrReq optional in getCsrfToken() (#1850) 2021-04-25 14:10:21 +02:00
Balázs Orbán
065d9eb310 chore(release): do not mark released PRs/issues (#1845) 2021-04-24 23:17:24 +02:00
Thanayut T
5da19f3c9a feat(provider): add WordPress.com provider (#1837) 2021-04-24 10:48:44 +02:00
Balázs Orbán
88ec3bad71 chore: move files from root 2021-04-24 00:44:08 +02:00
Lluis Agusti
5ab7868533 chore(ci): remove Node 10 and add Node 16 (#1830)
* chore(github): add CODEOWNERS

* chore(ci): remove Node 10 and add Node 16
2021-04-24 00:20:50 +02:00
Lluis Agusti
835dda0899 chore(github): add CODEOWNERS (#1827) 2021-04-24 00:17:19 +02:00
Wilkins Fernandez
ad4709764a docs: update import for providers (#1823)
Updates the names export from `providers` to `getProviders`.
2021-04-23 14:58:53 +02:00
Michał Bundyra
55a2932973 fix(ts): add Mailchimp provider (#1821) 2021-04-23 13:11:13 +02:00
14 changed files with 90 additions and 20 deletions

1
.github/CODEOWNERS vendored Normal file
View File

@@ -0,0 +1 @@
/types/ @balazsorban44 @lluia

View File

View File

@@ -4,22 +4,22 @@ name: Lint/Build
on:
push:
branches:
- main
- beta
- next
branches:
- main
- beta
- next
pull_request:
branches:
- main
- beta
- next
- main
- beta
- next
jobs:
lint-and-build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10, 12, 14]
node-version: [12, 14, 16]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
@@ -29,4 +29,4 @@ jobs:
- name: Install dependencies
uses: bahmutov/npm-install@v1
- run: npm run lint
- run: npm run build
- run: npm run build

View File

@@ -30,7 +30,7 @@ jobs:
strategy:
matrix:
node-version: [10, 12, 14]
node-version: [12, 14, 16]
steps:
- uses: actions/checkout@v2

View File

@@ -19,6 +19,8 @@ jobs:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 14
- name: Install dependencies
uses: bahmutov/npm-install@v1
- name: Check types

View File

@@ -180,6 +180,18 @@
"name": "next",
"prerelease": true
}
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/npm",
[
"@semantic-release/github",
{
"releasedLabels": false,
"successComment": false
}
]
]
},
"funding": [

View File

@@ -0,0 +1,23 @@
export default function WordPress(options) {
return {
id: "wordpress",
name: "WordPress.com",
type: "oauth",
version: "2.0",
scope: "auth",
params: { grant_type: "authorization_code" },
accessTokenUrl: "https://public-api.wordpress.com/oauth2/token",
authorizationUrl:
"https://public-api.wordpress.com/oauth2/authorize?response_type=code",
profileUrl: "https://public-api.wordpress.com/rest/v1/me",
profile(profile) {
return {
id: profile.ID,
name: profile.display_name,
email: profile.email,
image: profile.avatar_URL,
}
},
...options,
}
}

View File

@@ -1,5 +1,6 @@
# Rename file to .env and populate values
# to be able to run tests
# To be able to run tests:
# 1. copy to the root folder and rename to .env
# 2. Populate with values
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_TWITTER_ID=
NEXTAUTH_TWITTER_SECRET=

View File

@@ -2,14 +2,13 @@
#
# Note: Uses Docker Compose v2 as v3 doesn't currently support extends.
# https://docs.docker.com/compose/compose-file/compose-file-v2/
version: '2.3'
version: "2.3"
services:
app:
build:
context: ../../
dockerfile: Dockerfile
dockerfile: ./test/Dockerfile
environment:
# Set env vars in your current terminal or in .env in the root directory
- NEXTAUTH_URL=${NEXTAUTH_URL}

4
types/client.d.ts vendored
View File

@@ -32,7 +32,7 @@ export function useSession(): [Session | null, boolean]
*
* [Documentation](https://next-auth.js.org/getting-started/client#getsession)
*/
export function getSession(options: GetSessionOptions): Promise<Session | null>
export function getSession(options?: GetSessionOptions): Promise<Session | null>
/**
* Alias for `getSession`
@@ -52,7 +52,7 @@ export const session: typeof getSession
*
* [Documentation](https://next-auth.js.org/getting-started/client#getcsrftoken)
*/
export function getCsrfToken(ctxOrReq: CtxOrReq): Promise<string | null>
export function getCsrfToken(ctxOrReq?: CtxOrReq): Promise<string | null>
/**
* Alias for `getCsrfToken`

View File

@@ -77,6 +77,7 @@ export type OAuthProviderType =
| "Kakao"
| "LINE"
| "LinkedIn"
| "Mailchimp"
| "MailRu"
| "Medium"
| "Netlify"
@@ -90,6 +91,7 @@ export type OAuthProviderType =
| "Twitch"
| "Twitter"
| "VK"
| "WordPress"
| "Yandex"
| "Zoho"

View File

@@ -60,7 +60,7 @@ By default, the built-in pages will follow the system theme, utilizing the [`pre
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.js"
import { providers, signIn } from 'next-auth/client'
import { getProviders, signIn } from 'next-auth/client'
export default function SignIn({ providers }) {
return (
@@ -76,7 +76,7 @@ export default function SignIn({ providers }) {
// This is the recommended way for Next.js 9.3 or newer
export async function getServerSideProps(context){
const providers = await providers()
const providers = await getProviders()
return {
props: { providers }
}
@@ -86,7 +86,7 @@ export async function getServerSideProps(context){
// If older than Next.js 9.3
SignIn.getInitialProps = async () => {
return {
providers: await providers()
providers: await getProviders()
}
}
*/

View File

@@ -0,0 +1,30 @@
---
id: wordpress
title: WordPress.com
---
## Documentation
https://developer.wordpress.com/docs/oauth2/
## Configuration
https://developer.wordpress.com/apps/
## Example
```js
import Providers from `next-auth/providers`
...
providers: [
Providers.WordPress({
clientId: process.env.WORDPRESS_CLIENT_ID,
clientSecret: process.env.WORDPRESS_CLIENT_SECRET
})
}
...
```
:::tip
Register your application to obtain Client ID and Client Secret at https://developer.wordpress.com/apps/ Select Type as Web and set Redirect URL to `http://example.com/api/auth/callback/wordpress` where example.com is your site domain.
:::