Files
payloadcms/test/login-with-username/config.ts
Jarrod Flesch 1ebd54b315 feat: allows loginWithUsername to not require username (#7480)
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
  },
},
```
2024-08-05 11:35:01 -04:00

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