Allows username to be optional when using the new loginWithUsername
feature. This can be done by the following:
```ts
auth: {
loginWithUsername: {
requireUsername: false, // <-- new property, default true
requireEmail: false, // default: false
allowEmailLogin: true, // default false
},
},
```
39 lines
837 B
TypeScript
39 lines
837 B
TypeScript
import path from 'path'
|
|
import { fileURLToPath } from 'url'
|
|
|
|
import { buildConfigWithDefaults } from '../buildConfigWithDefaults.js'
|
|
|
|
const filename = fileURLToPath(import.meta.url)
|
|
const dirname = path.dirname(filename)
|
|
|
|
export const LoginWithUsernameConfig = buildConfigWithDefaults({
|
|
typescript: {
|
|
outputFile: path.resolve(dirname, 'payload-types.ts'),
|
|
},
|
|
collections: [
|
|
{
|
|
slug: 'users',
|
|
auth: {
|
|
loginWithUsername: {
|
|
requireEmail: false,
|
|
allowEmailLogin: false,
|
|
},
|
|
},
|
|
fields: [],
|
|
},
|
|
{
|
|
slug: 'login-with-either',
|
|
auth: {
|
|
loginWithUsername: {
|
|
requireEmail: false,
|
|
allowEmailLogin: true,
|
|
requireUsername: false,
|
|
},
|
|
},
|
|
fields: [],
|
|
},
|
|
],
|
|
})
|
|
|
|
export default LoginWithUsernameConfig
|