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 11import { 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'
33
44export const importMap = {
55 "payload-authjs/components#AccountRowLabel" : AccountRowLabel_06d0cb594d8f6ba2ac35015f930c882e ,
6- "payload-authjs/components#SignInWithAuthjsButton " : SignInWithAuthjsButton_06d0cb594d8f6ba2ac35015f930c882e
6+ "payload-authjs/components#SignInButton " : SignInButton_06d0cb594d8f6ba2ac35015f930c882e
77}
Original file line number Diff line number Diff line change 11import { 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'
33
44export const importMap = {
55 "payload-authjs/components#AccountRowLabel" : AccountRowLabel_06d0cb594d8f6ba2ac35015f930c882e ,
6- "payload-authjs/components#SignInWithAuthjsButton " : SignInWithAuthjsButton_06d0cb594d8f6ba2ac35015f930c882e
6+ "payload-authjs/components#SignInButton " : SignInButton_06d0cb594d8f6ba2ac35015f930c882e
77}
Original file line number Diff line number Diff line change 11import { 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'
33
44export const importMap = {
55 "payload-authjs/components#AccountRowLabel" : AccountRowLabel_06d0cb594d8f6ba2ac35015f930c882e ,
6- "payload-authjs/components#SignInWithAuthjsButton " : SignInWithAuthjsButton_06d0cb594d8f6ba2ac35015f930c882e
6+ "payload-authjs/components#SignInButton " : SignInButton_06d0cb594d8f6ba2ac35015f930c882e
77}
Original file line number Diff line number Diff line change 11import { 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'
33import { default as default_2c1e1c35da30a80d88551f9fcc61be66 } from '../../../payload/components/Greeting'
44
55export const importMap = {
66 "payload-authjs/components#AccountRowLabel" : AccountRowLabel_06d0cb594d8f6ba2ac35015f930c882e ,
7- "payload-authjs/components#SignInWithAuthjsButton " : SignInWithAuthjsButton_06d0cb594d8f6ba2ac35015f930c882e ,
7+ "payload-authjs/components#SignInButton " : SignInButton_06d0cb594d8f6ba2ac35015f930c882e ,
88 "/Greeting#default" : default_2c1e1c35da30a80d88551f9fcc61be66
99}
Original file line number Diff line number Diff line change 33 "jsc" : {
44 "target" : " esnext" ,
55 "parser" : {
6- "syntax" : " typescript"
6+ "syntax" : " typescript" ,
7+ "tsx" : true
78 },
89 "transform" : {
910 "react" : {
Original file line number Diff line number Diff line change 66 "build" : {
77 "executor" : " @nx/js:swc" ,
88 "options" : {
9- "main" : " packages/payload-authjs/src/index.ts" ,
10- "tsConfig" : " packages/payload-authjs/tsconfig.lib.json" ,
11- "outputPath" : " packages/payload-authjs/dist" ,
129 "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+ ]
1421 },
1522 "cache" : true
1623 },
Original file line number Diff line number Diff line change 11import 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+ } ;
217
318/**
419 * 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