File tree Expand file tree Collapse file tree 3 files changed +30
-20
lines changed
payload-authjs/src/payload/collection Expand file tree Collapse file tree 3 files changed +30
-20
lines changed Original file line number Diff line number Diff line change @@ -131,7 +131,6 @@ export interface UserAuthOperations {
131131 */
132132export interface User {
133133 id : string ;
134- email : string ;
135134 emailVerified ?: string | null ;
136135 name ?: string | null ;
137136 image ?: string | null ;
@@ -170,6 +169,7 @@ export interface User {
170169 enableAPIKey ?: boolean | null ;
171170 apiKey ?: string | null ;
172171 apiKeyIndex ?: string | null ;
172+ email : string ;
173173 username ?: string | null ;
174174 resetPasswordToken ?: string | null ;
175175 resetPasswordExpiration ?: string | null ;
@@ -253,7 +253,6 @@ export interface PayloadMigration {
253253 */
254254export interface UsersSelect < T extends boolean = true > {
255255 id ?: T ;
256- email ?: T ;
257256 emailVerified ?: T ;
258257 name ?: T ;
259258 image ?: T ;
@@ -294,6 +293,7 @@ export interface UsersSelect<T extends boolean = true> {
294293 enableAPIKey ?: T ;
295294 apiKey ?: T ;
296295 apiKeyIndex ?: T ;
296+ email ?: T ;
297297 username ?: T ;
298298 resetPasswordToken ?: T ;
299299 resetPasswordExpiration ?: T ;
Original file line number Diff line number Diff line change 11import type { Field } from "payload" ;
2+ import type { AuthjsPluginConfig } from "src/payload/plugin" ;
23
34/**
45 * General fields for a user
56 *
67 * @see https://authjs.dev/concepts/database-models
78 */
8- export const generalFields : Field [ ] = [
9- {
10- type : "row" ,
11- fields : [
12- {
13- name : "email" ,
14- type : "email" ,
15- required : true ,
16- unique : true ,
17- index : true ,
18- } ,
19- {
20- name : "emailVerified" ,
21- type : "date" ,
22- } ,
23- ] ,
24- } ,
9+ export const generalFields = ( pluginOptions : AuthjsPluginConfig ) : Field [ ] => [
10+ ...( pluginOptions . enableLocalStrategy
11+ ? ( [
12+ {
13+ name : "emailVerified" ,
14+ type : "date" ,
15+ } ,
16+ ] satisfies Field [ ] )
17+ : ( [
18+ {
19+ type : "row" ,
20+ fields : [
21+ {
22+ name : "email" ,
23+ type : "email" ,
24+ required : true ,
25+ unique : true ,
26+ index : true ,
27+ } ,
28+ {
29+ name : "emailVerified" ,
30+ type : "date" ,
31+ } ,
32+ ] ,
33+ } ,
34+ ] satisfies Field [ ] ) ) ,
2535 {
2636 name : "name" ,
2737 type : "text" ,
Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ export const generateUsersCollection = (
5050 tabs : [
5151 {
5252 label : "General" ,
53- fields : generalFields ,
53+ fields : generalFields ( pluginOptions ) ,
5454 } ,
5555 {
5656 label : "Accounts" ,
You can’t perform that action at this time.
0 commit comments