Auth flow functional
This commit is contained in:
@ -30,12 +30,18 @@ const Makers: CollectionConfig = {
|
||||
label: 'Location',
|
||||
required: true
|
||||
},
|
||||
{
|
||||
name: 'admins',
|
||||
type: 'relationship',
|
||||
relationTo: 'users',
|
||||
hasMany: true,
|
||||
},
|
||||
{
|
||||
name: 'stock',
|
||||
type: 'relationship',
|
||||
relationTo: 'products',
|
||||
hasMany: true,
|
||||
},
|
||||
}
|
||||
],
|
||||
};
|
||||
|
||||
|
@ -31,6 +31,12 @@ const Retailers: CollectionConfig = {
|
||||
label: 'Location',
|
||||
required: true
|
||||
},
|
||||
{
|
||||
name: 'admins',
|
||||
type: 'relationship',
|
||||
relationTo: 'users',
|
||||
hasMany: true,
|
||||
},
|
||||
{
|
||||
name: 'stock',
|
||||
type: 'relationship',
|
||||
|
@ -2,12 +2,17 @@ import { CollectionConfig } from 'payload/types';
|
||||
|
||||
const Users: CollectionConfig = {
|
||||
slug: 'users',
|
||||
auth: true,
|
||||
admin: {
|
||||
useAsTitle: 'email',
|
||||
},
|
||||
access: {
|
||||
read: () => true,
|
||||
|
||||
},
|
||||
auth: {
|
||||
tokenExpiration: 7200, // How many seconds to keep the user logged in
|
||||
verify: false, // Require email verification before being allowed to authenticate
|
||||
maxLoginAttempts: 5, // Automatically lock a user out after X amount of failed logins
|
||||
lockTime: 600 * 1000, // Time period to allow the max login attempts
|
||||
},
|
||||
fields: [
|
||||
// Email added by default
|
||||
@ -20,20 +25,7 @@ const Users: CollectionConfig = {
|
||||
name: 'phoneNumber',
|
||||
type: 'number',
|
||||
required: false
|
||||
},
|
||||
{
|
||||
name: 'adminOfMakers',
|
||||
type: 'relationship',
|
||||
relationTo: 'makers',
|
||||
hasMany: true,
|
||||
},
|
||||
{
|
||||
name: 'adminOfRetailers',
|
||||
type: 'relationship',
|
||||
relationTo: 'retailers',
|
||||
|
||||
hasMany: true,
|
||||
},
|
||||
}
|
||||
],
|
||||
};
|
||||
|
||||
|
@ -21,6 +21,7 @@ payload.init({
|
||||
|
||||
const corsOptions = {
|
||||
origin: 'http://localhost:3000',
|
||||
credentials: true
|
||||
};
|
||||
|
||||
app.use(cors(corsOptions));
|
||||
|
Reference in New Issue
Block a user