File tree Expand file tree Collapse file tree 15 files changed +155
-106
lines changed
basic/src/app/(payload)/admin
multiple-auth-collections/src/app/(payload)/admin
with-payload-local-strategy/src/app/(payload)/admin
dev/src/app/(payload)/admin Expand file tree Collapse file tree 15 files changed +155
-106
lines changed Original file line number Diff line number Diff line change 1
1
import { AccountRowLabel as AccountRowLabel_06d0cb594d8f6ba2ac35015f930c882e } from 'payload-authjs/components'
2
- import { SignInWithAuthjsButton as SignInWithAuthjsButton_06d0cb594d8f6ba2ac35015f930c882e } from 'payload-authjs/components'
2
+ import { SignInButton as SignInButton_06d0cb594d8f6ba2ac35015f930c882e } from 'payload-authjs/components'
3
3
4
4
export const importMap = {
5
5
"payload-authjs/components#AccountRowLabel" : AccountRowLabel_06d0cb594d8f6ba2ac35015f930c882e ,
6
- "payload-authjs/components#SignInWithAuthjsButton " : SignInWithAuthjsButton_06d0cb594d8f6ba2ac35015f930c882e
6
+ "payload-authjs/components#SignInButton " : SignInButton_06d0cb594d8f6ba2ac35015f930c882e
7
7
}
Original file line number Diff line number Diff line change 1
1
import { AccountRowLabel as AccountRowLabel_06d0cb594d8f6ba2ac35015f930c882e } from 'payload-authjs/components'
2
- import { SignInWithAuthjsButton as SignInWithAuthjsButton_06d0cb594d8f6ba2ac35015f930c882e } from 'payload-authjs/components'
2
+ import { SignInButton as SignInButton_06d0cb594d8f6ba2ac35015f930c882e } from 'payload-authjs/components'
3
3
4
4
export const importMap = {
5
5
"payload-authjs/components#AccountRowLabel" : AccountRowLabel_06d0cb594d8f6ba2ac35015f930c882e ,
6
- "payload-authjs/components#SignInWithAuthjsButton " : SignInWithAuthjsButton_06d0cb594d8f6ba2ac35015f930c882e
6
+ "payload-authjs/components#SignInButton " : SignInButton_06d0cb594d8f6ba2ac35015f930c882e
7
7
}
Original file line number Diff line number Diff line change 1
1
import { AccountRowLabel as AccountRowLabel_06d0cb594d8f6ba2ac35015f930c882e } from 'payload-authjs/components'
2
- import { SignInWithAuthjsButton as SignInWithAuthjsButton_06d0cb594d8f6ba2ac35015f930c882e } from 'payload-authjs/components'
2
+ import { SignInButton as SignInButton_06d0cb594d8f6ba2ac35015f930c882e } from 'payload-authjs/components'
3
3
4
4
export const importMap = {
5
5
"payload-authjs/components#AccountRowLabel" : AccountRowLabel_06d0cb594d8f6ba2ac35015f930c882e ,
6
- "payload-authjs/components#SignInWithAuthjsButton " : SignInWithAuthjsButton_06d0cb594d8f6ba2ac35015f930c882e
6
+ "payload-authjs/components#SignInButton " : SignInButton_06d0cb594d8f6ba2ac35015f930c882e
7
7
}
Original file line number Diff line number Diff line change 1
1
import { AccountRowLabel as AccountRowLabel_06d0cb594d8f6ba2ac35015f930c882e } from 'payload-authjs/components'
2
- import { SignInWithAuthjsButton as SignInWithAuthjsButton_06d0cb594d8f6ba2ac35015f930c882e } from 'payload-authjs/components'
2
+ import { SignInButton as SignInButton_06d0cb594d8f6ba2ac35015f930c882e } from 'payload-authjs/components'
3
3
import { default as default_2c1e1c35da30a80d88551f9fcc61be66 } from '../../../payload/components/Greeting'
4
4
5
5
export const importMap = {
6
6
"payload-authjs/components#AccountRowLabel" : AccountRowLabel_06d0cb594d8f6ba2ac35015f930c882e ,
7
- "payload-authjs/components#SignInWithAuthjsButton " : SignInWithAuthjsButton_06d0cb594d8f6ba2ac35015f930c882e ,
7
+ "payload-authjs/components#SignInButton " : SignInButton_06d0cb594d8f6ba2ac35015f930c882e ,
8
8
"/Greeting#default" : default_2c1e1c35da30a80d88551f9fcc61be66
9
9
}
Original file line number Diff line number Diff line change 3
3
"jsc" : {
4
4
"target" : " esnext" ,
5
5
"parser" : {
6
- "syntax" : " typescript"
6
+ "syntax" : " typescript" ,
7
+ "tsx" : true
7
8
},
8
9
"transform" : {
9
10
"react" : {
Original file line number Diff line number Diff line change 6
6
"build" : {
7
7
"executor" : " @nx/js:swc" ,
8
8
"options" : {
9
- "main" : " packages/payload-authjs/src/index.ts" ,
10
- "tsConfig" : " packages/payload-authjs/tsconfig.lib.json" ,
11
- "outputPath" : " packages/payload-authjs/dist" ,
12
9
"rootDir" : " packages/payload-authjs/src" ,
13
- "stripLeadingPaths" : true
10
+ "outputPath" : " packages/payload-authjs/dist" ,
11
+ "tsConfig" : " packages/payload-authjs/tsconfig.lib.json" ,
12
+ "stripLeadingPaths" : true ,
13
+ "main" : " packages/payload-authjs/src/index.ts" ,
14
+ "assets" : [
15
+ {
16
+ "input" : " packages/payload-authjs/src" ,
17
+ "glob" : " **/*.css" ,
18
+ "output" : " ."
19
+ }
20
+ ]
14
21
},
15
22
"cache" : true
16
23
},
Original file line number Diff line number Diff line change 1
1
import type { NextAuthConfig } from "next-auth" ;
2
+ import type { Provider } from "next-auth/providers" ;
3
+
4
+ /**
5
+ * Get provider metadata
6
+ */
7
+ export const getProviderMetadata = ( provider : Provider ) => {
8
+ const providerOptions = typeof provider === "function" ? provider ( ) : provider ;
9
+
10
+ return {
11
+ type : providerOptions . type ,
12
+ id : ( providerOptions . options ?. id as string | undefined ) ?? providerOptions . id ,
13
+ name : ( providerOptions . options ?. name as string | undefined ) ?? providerOptions . name ,
14
+ icon : `https://authjs.dev/img/providers/${ providerOptions . id } .svg` ,
15
+ } ;
16
+ } ;
2
17
3
18
/**
4
19
* Check if an email provider is available in the authjs config
Original file line number Diff line number Diff line change
1
+ .payload-authjs-sign-in-button {
2
+ width : 100% ;
3
+ margin-block : 8px ;
4
+ }
Original file line number Diff line number Diff line change
1
+ "use client" ;
2
+
3
+ import { Button } from "@payloadcms/ui" ;
4
+ import { signIn } from "next-auth/react" ;
5
+ import type { ReactNode } from "react" ;
6
+ import type { getProviderMetadata } from "../../authjs/utils/config" ;
7
+ import "./index.css" ;
8
+
9
+ export type SignInButtonOptions = {
10
+ /**
11
+ * Icon to display on the button
12
+ *
13
+ * @default
14
+ * ```tsx
15
+ * <img src={provider.iconUrl} alt={`Provider ${provider.name}`} />
16
+ * ```
17
+ */
18
+ icon ?: ReactNode | ( ( provider : ReturnType < typeof getProviderMetadata > ) => ReactNode ) ;
19
+ /**
20
+ * Text to display on the button
21
+ *
22
+ * @default
23
+ * ```tsx
24
+ * <>Sign in with <strong>{provider.name}</strong></>
25
+ * ```
26
+ */
27
+ text ?: ReactNode | ( ( provider : ReturnType < typeof getProviderMetadata > ) => ReactNode ) ;
28
+ } ;
29
+
30
+ export type SignInButtonProps = {
31
+ provider : ReturnType < typeof getProviderMetadata > ;
32
+ icon ?: ReactNode ;
33
+ text ?: ReactNode ;
34
+ } ;
35
+
36
+ /**
37
+ * A button to sign in with a Auth.js provider
38
+ */
39
+ export const SignInButton = ( {
40
+ provider,
41
+ icon = < img src = { provider . icon } alt = { `Provider ${ provider . name } ` } /> ,
42
+ text = (
43
+ < >
44
+ Sign in with < strong > { provider . name } </ strong >
45
+ </ >
46
+ ) ,
47
+ } : SignInButtonProps ) => {
48
+ return (
49
+ < Button
50
+ className = "payload-authjs-sign-in-button"
51
+ size = "large"
52
+ buttonStyle = "pill"
53
+ icon = { icon }
54
+ iconPosition = "left"
55
+ onClick = { ( ) => signIn ( provider . id ) }
56
+ >
57
+ { text }
58
+ </ Button >
59
+ ) ;
60
+ } ;
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments