Skip to content

Commit 14be9d6

Browse files
Merge pull request #123 from authsmith/0.7.2
0.7.2
2 parents 0469ed0 + deceb60 commit 14be9d6

File tree

19 files changed

+78
-456
lines changed

19 files changed

+78
-456
lines changed

src/core/errors/apiErrors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class MissingEmailAPIError extends AuthAPIError {
3333

3434
export class UnVerifiedAccountAPIError extends AuthAPIError {
3535
constructor() {
36-
super("Account is not verfified", ErrorKind.BadRequest)
36+
super("Account is not verified", ErrorKind.BadRequest)
3737
}
3838
}
3939

src/core/protocols/oauth/oidc_callback.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,14 @@ export async function OIDCCallback(
104104
userInfoResponse,
105105
)
106106

107-
if (!result.email_verified) {
108-
return new UnVerifiedAccountAPIError()
109-
}
110-
111107
if (!result.email) {
112108
return new MissingEmailAPIError()
113109
}
114110

111+
if (!providerConfig.skip_email_verification && !result.email_verified) {
112+
return new UnVerifiedAccountAPIError()
113+
}
114+
115115
const userData = {
116116
email: result.email,
117117
name: result.name ?? "",

src/providers/oauth2/apple.ts

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,19 @@ const authorization_server: AuthorizationServer = {
2020
*
2121
* #### Callback or Redirect URL pattern
2222
*
23-
* - For Admin
2423
* ```
25-
* https://example.com/api/admin/oauth/callback/apple
26-
* ```
27-
*
28-
* - For App
29-
* ```
30-
* https://example.com/api/{app_name}/oauth/callback/apple
24+
* https://example.com/api/{name}/oauth/callback/apple
3125
* ```
3226
*
3327
* #### Plugin Setup
3428
*
3529
* ```ts
3630
* import { Plugin } from 'payload'
37-
* import {adminAuthPlugin, appAuthPlugin} from "payload-auth-plugin"
31+
* import {authPlugin} from "payload-auth-plugin"
3832
* import {AppleOAuth2Provider} from "payload-auth-plugin/providers"
3933
*
40-
* export const plugins: Plugins[] = [
41-
* //For Admin
42-
* adminAuthPlugin({
43-
* accountsCollectionSlug: 'adminAccounts',
34+
* export const plugins: Plugin[] = [
35+
* authPlugin({
4436
* providers:[
4537
* AppleOAuth2Provider({
4638
* client_id: process.env.APPLE_CLIENT_ID as string,
@@ -49,20 +41,6 @@ const authorization_server: AuthorizationServer = {
4941
* ]
5042
* })
5143
*
52-
* // For App
53-
* appAuthPlugin({
54-
* name: 'app'
55-
* secret: process.env.APP_AUTH_SECRET,
56-
* accountsCollectionSlug: 'adminAccounts',
57-
* usersCollectionSlug: 'appUsers',
58-
* accountsCollectionSlug: 'appAccounts',
59-
* providers:[
60-
* AppleOAuth2Provider({
61-
* client_id: process.env.APPLE_CLIENT_ID as string,
62-
* client_secret: process.env.APPLE_CLIENT_SECRET as string,
63-
* })
64-
* ]
65-
* })
6644
* ]
6745
* ```
6846
*

src/providers/oauth2/atlassian.ts

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,19 @@ type AtlassianAuthConfig = OAuthBaseProviderConfig
2121
*
2222
* #### Callback or Redirect URL pattern
2323
*
24-
* - For Admin
2524
* ```
26-
* https://example.com/api/admin/oauth/callback/atlassian
27-
* ```
28-
*
29-
* - For App
30-
* ```
31-
* https://example.com/api/{app_name}/oauth/callback/atlassian
25+
* https://example.com/api/{name}/oauth/callback/atlassian
3226
* ```
3327
*
3428
* #### Plugin Setup
3529
*
3630
* ```ts
3731
* import { Plugin } from 'payload'
38-
* import {adminAuthPlugin, appAuthPlugin} from "payload-auth-plugin"
32+
* import {authPlugin} from "payload-auth-plugin"
3933
* import {AtlassianAuthProvider} from "payload-auth-plugin/providers"
4034
*
4135
* export const plugins: Plugins[] = [
42-
* //For Admin
43-
* adminAuthPlugin({
44-
* accountsCollectionSlug: 'adminAccounts',
36+
* authPlugin({
4537
* providers:[
4638
* AtlassianAuthProvider({
4739
* client_id: process.env.ATLASSIAN_CLIENT_ID as string,
@@ -50,20 +42,6 @@ type AtlassianAuthConfig = OAuthBaseProviderConfig
5042
* ]
5143
* })
5244
*
53-
* // For App
54-
* appAuthPlugin({
55-
* name: 'app'
56-
* secret: process.env.APP_AUTH_SECRET,
57-
* accountsCollectionSlug: 'adminAccounts',
58-
* usersCollectionSlug: 'appUsers',
59-
* accountsCollectionSlug: 'appAccounts',
60-
* providers:[
61-
* AtlassianAuthProvider({
62-
* client_id: process.env.ATLASSIAN_CLIENT_ID as string,
63-
* client_secret: process.env.ATLASSIAN_CLIENT_SECRET as string,
64-
* })
65-
* ]
66-
* })
6745
* ]
6846
* ```
6947
*

src/providers/oauth2/auth0.ts

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,43 +14,19 @@ interface Auth0AuthConfig extends OAuthBaseProviderConfig {
1414
*
1515
* #### Callback or Redirect URL pattern
1616
*
17-
* - For Admin
1817
* ```
19-
* https://example.com/api/admin/oauth/callback/auth0
20-
* ```
21-
*
22-
* - For App
23-
* ```
24-
* https://example.com/api/{app_name}/oauth/callback/auth0
18+
* https://example.com/api/{name}/oauth/callback/auth0
2519
* ```
2620
*
2721
* #### Plugin Setup
2822
*
2923
* ```ts
3024
* import { Plugin } from 'payload'
31-
* import {adminAuthPlugin, appAuthPlugin} from "payload-auth-plugin"
25+
* import {authPlugin} from "payload-auth-plugin"
3226
* import {Auth0AuthProvider} from "payload-auth-plugin/providers"
3327
*
34-
* export const plugins: Plugins[] = [
35-
* //For Admin
36-
* adminAuthPlugin({
37-
* accountsCollectionSlug: 'adminAccounts',
38-
* providers:[
39-
* Auth0AuthProvider({
40-
* client_id: process.env.AUTH0_CLIENT_ID as string,
41-
* client_secret: process.env.AUTH0_CLIENT_SECRET as string,
42-
* domain: process.env.AUTH0_DOMAIN as string,
43-
* })
44-
* ]
45-
* })
46-
*
47-
* // For App
48-
* appAuthPlugin({
49-
* name: 'app'
50-
* secret: process.env.APP_AUTH_SECRET,
51-
* accountsCollectionSlug: 'adminAccounts',
52-
* usersCollectionSlug: 'appUsers',
53-
* accountsCollectionSlug: 'appAccounts',
28+
* export const plugins: Plugin[] = [
29+
* authPlugin({
5430
* providers:[
5531
* Auth0AuthProvider({
5632
* client_id: process.env.AUTH0_CLIENT_ID as string,

src/providers/oauth2/discord.ts

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,44 +16,19 @@ type DiscordAuthConfig = OAuthBaseProviderConfig
1616
/**
1717
* Add Discord OAuth2 Provider
1818
*
19-
* #### Callback or Redirect URL pattern
20-
*
21-
* - For Admin
22-
* ```
23-
* https://example.com/api/admin/oauth/callback/discord
24-
* ```
25-
*
26-
* - For App
2719
* ```
28-
* https://example.com/api/{app_name}/oauth/callback/discord
20+
* https://example.com/api/{name}/oauth/callback/discord
2921
* ```
3022
*
3123
* #### Plugin Setup
3224
*
3325
* ```ts
3426
* import { Plugin } from 'payload'
35-
* import {adminAuthPlugin, appAuthPlugin} from "payload-auth-plugin"
27+
* import {authPlugin} from "payload-auth-plugin"
3628
* import {DiscordAuthProvider} from "payload-auth-plugin/providers"
3729
*
38-
* export const plugins: Plugins[] = [
39-
* //For Admin
40-
* adminAuthPlugin({
41-
* accountsCollectionSlug: 'adminAccounts',
42-
* providers:[
43-
* DiscordAuthProvider({
44-
* client_id: process.env.DISCORD_CLIENT_ID as string,
45-
* client_secret: process.env.DISCORD_CLIENT_SECRET as string,
46-
* })
47-
* ]
48-
* })
49-
*
50-
* // For App
51-
* appAuthPlugin({
52-
* name: 'app'
53-
* secret: process.env.APP_AUTH_SECRET,
54-
* accountsCollectionSlug: 'adminAccounts',
55-
* usersCollectionSlug: 'appUsers',
56-
* accountsCollectionSlug: 'appAccounts',
30+
* export const plugins: Plugin[] = [
31+
* authPlugin({
5732
* providers:[
5833
* DiscordAuthProvider({
5934
* client_id: process.env.DISCORD_CLIENT_ID as string,

src/providers/oauth2/facebook.ts

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,42 +20,19 @@ type FacebookAuthConfig = OAuthBaseProviderConfig
2020
*
2121
* #### Callback or Redirect URL pattern
2222
*
23-
* - For Admin
2423
* ```
25-
* https://example.com/api/admin/oauth/callback/facebook
26-
* ```
27-
*
28-
* - For App
29-
* ```
30-
* https://example.com/api/{app_name}/oauth/callback/facebook
24+
* https://example.com/api/{name}/oauth/callback/facebook
3125
* ```
3226
*
3327
* #### Plugin Setup
3428
*
3529
* ```ts
3630
* import { Plugin } from 'payload'
37-
* import {adminAuthPlugin, appAuthPlugin} from "payload-auth-plugin"
31+
* import {authPlugin} from "payload-auth-plugin"
3832
* import {FacebookAuthProvider} from "payload-auth-plugin/providers"
3933
*
40-
* export const plugins: Plugins[] = [
41-
* //For Admin
42-
* adminAuthPlugin({
43-
* accountsCollectionSlug: 'adminAccounts',
44-
* providers:[
45-
* FacebookAuthProvider({
46-
* client_id: process.env.FACEBOOK_CLIENT_ID as string,
47-
* client_secret: process.env.FACEBOOK_CLIENT_SECRET as string,
48-
* })
49-
* ]
50-
* })
51-
*
52-
* // For App
53-
* appAuthPlugin({
54-
* name: 'app'
55-
* secret: process.env.APP_AUTH_SECRET,
56-
* accountsCollectionSlug: 'adminAccounts',
57-
* usersCollectionSlug: 'appUsers',
58-
* accountsCollectionSlug: 'appAccounts',
34+
* export const plugins: Plugin[] = [
35+
* authPlugin({
5936
* providers:[
6037
* FacebookAuthProvider({
6138
* client_id: process.env.FACEBOOK_CLIENT_ID as string,
@@ -65,7 +42,6 @@ type FacebookAuthConfig = OAuthBaseProviderConfig
6542
* })
6643
* ]
6744
* ```
68-
*
6945
*/
7046

7147
function FacebookAuthProvider(

src/providers/oauth2/github.ts

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,42 +19,19 @@ type GitHubAuthConfig = OAuthBaseProviderConfig
1919
*
2020
* #### Callback or Redirect URL pattern
2121
*
22-
* - For Admin
2322
* ```
24-
* https://example.com/api/admin/oauth/callback/github
25-
* ```
26-
*
27-
* - For App
28-
* ```
29-
* https://example.com/api/{app_name}/oauth/callback/github
23+
* https://example.com/api/{name}/oauth/callback/github
3024
* ```
3125
*
3226
* #### Plugin Setup
3327
*
3428
* ```ts
3529
* import { Plugin } from 'payload'
36-
* import {adminAuthPlugin, appAuthPlugin} from "payload-auth-plugin"
30+
* import {authPlugin} from "payload-auth-plugin"
3731
* import {GithubAuthProvider} from "payload-auth-plugin/providers"
3832
*
39-
* export const plugins: Plugins[] = [
40-
* //For Admin
41-
* adminAuthPlugin({
42-
* accountsCollectionSlug: 'adminAccounts',
43-
* providers:[
44-
* GithubAuthProvider({
45-
* client_id: process.env.GITHUB_CLIENT_ID as string,
46-
* client_secret: process.env.GITHUB_CLIENT_SECRET as string,
47-
* })
48-
* ]
49-
* })
50-
*
51-
* // For App
52-
* appAuthPlugin({
53-
* name: 'app'
54-
* secret: process.env.APP_AUTH_SECRET,
55-
* accountsCollectionSlug: 'adminAccounts',
56-
* usersCollectionSlug: 'appUsers',
57-
* accountsCollectionSlug: 'appAccounts',
33+
* export const plugins: Plugin[] = [
34+
* authPlugin({
5835
* providers:[
5936
* GithubAuthProvider({
6037
* client_id: process.env.GITHUB_CLIENT_ID as string,

src/providers/oauth2/jumpcloud.ts

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -19,42 +19,19 @@ type JumpCloudAuthConfig = OAuthBaseProviderConfig
1919
*
2020
* #### Callback or Redirect URL pattern
2121
*
22-
* - For Admin
2322
* ```
24-
* https://example.com/api/admin/oauth/callback/jumpcloud
25-
* ```
26-
*
27-
* - For App
28-
* ```
29-
* https://example.com/api/{app_name}/oauth/callback/jumpcloud
23+
* https://example.com/api/{name}/oauth/callback/jumpcloud
3024
* ```
3125
*
3226
* #### Plugin Setup
3327
*
3428
* ```ts
3529
* import { Plugin } from 'payload'
36-
* import {adminAuthPlugin, appAuthPlugin} from "payload-auth-plugin"
30+
* import {authPlugin} from "payload-auth-plugin"
3731
* import {JumpCloudAuthProvider} from "payload-auth-plugin/providers"
3832
*
39-
* export const plugins: Plugins[] = [
40-
* //For Admin
41-
* adminAuthPlugin({
42-
* accountsCollectionSlug: 'adminAccounts',
43-
* providers:[
44-
* JumpCloudAuthProvider({
45-
* client_id: process.env.JUMP_CLOUD_CLIENT_ID as string,
46-
* client_secret: process.env.JUMP_CLOUD_CLIENT_SECRET as string,
47-
* })
48-
* ]
49-
* })
50-
*
51-
* // For App
52-
* appAuthPlugin({
53-
* name: 'app'
54-
* secret: process.env.APP_AUTH_SECRET,
55-
* accountsCollectionSlug: 'adminAccounts',
56-
* usersCollectionSlug: 'appUsers',
57-
* accountsCollectionSlug: 'appAccounts',
33+
* export const plugins: Plugin[] = [
34+
* authPlugin({
5835
* providers:[
5936
* JumpCloudAuthProvider({
6037
* client_id: process.env.JUMP_CLOUD_CLIENT_ID as string,
@@ -63,8 +40,6 @@ type JumpCloudAuthConfig = OAuthBaseProviderConfig
6340
* ]
6441
* })
6542
* ]
66-
* ```
67-
*
6843
*/
6944

7045
function JumpCloudAuthProvider(

0 commit comments

Comments
 (0)