File tree 3 files changed +30
-20
lines changed
payload-authjs/src/payload/collection
3 files changed +30
-20
lines changed Original file line number Diff line number Diff line change @@ -131,7 +131,6 @@ export interface UserAuthOperations {
131
131
*/
132
132
export interface User {
133
133
id : string ;
134
- email : string ;
135
134
emailVerified ?: string | null ;
136
135
name ?: string | null ;
137
136
image ?: string | null ;
@@ -170,6 +169,7 @@ export interface User {
170
169
enableAPIKey ?: boolean | null ;
171
170
apiKey ?: string | null ;
172
171
apiKeyIndex ?: string | null ;
172
+ email : string ;
173
173
username ?: string | null ;
174
174
resetPasswordToken ?: string | null ;
175
175
resetPasswordExpiration ?: string | null ;
@@ -253,7 +253,6 @@ export interface PayloadMigration {
253
253
*/
254
254
export interface UsersSelect < T extends boolean = true > {
255
255
id ?: T ;
256
- email ?: T ;
257
256
emailVerified ?: T ;
258
257
name ?: T ;
259
258
image ?: T ;
@@ -294,6 +293,7 @@ export interface UsersSelect<T extends boolean = true> {
294
293
enableAPIKey ?: T ;
295
294
apiKey ?: T ;
296
295
apiKeyIndex ?: T ;
296
+ email ?: T ;
297
297
username ?: T ;
298
298
resetPasswordToken ?: T ;
299
299
resetPasswordExpiration ?: T ;
Original file line number Diff line number Diff line change 1
1
import type { Field } from "payload" ;
2
+ import type { AuthjsPluginConfig } from "src/payload/plugin" ;
2
3
3
4
/**
4
5
* General fields for a user
5
6
*
6
7
* @see https://authjs.dev/concepts/database-models
7
8
*/
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 [ ] ) ) ,
25
35
{
26
36
name : "name" ,
27
37
type : "text" ,
Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ export const generateUsersCollection = (
50
50
tabs : [
51
51
{
52
52
label : "General" ,
53
- fields : generalFields ,
53
+ fields : generalFields ( pluginOptions ) ,
54
54
} ,
55
55
{
56
56
label : "Accounts" ,
You can’t perform that action at this time.
0 commit comments