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
  },
},
```
This commit is contained in:
Jarrod Flesch
2024-08-05 11:35:01 -04:00
committed by GitHub
parent cdb2072a6d
commit 1ebd54b315
67 changed files with 884 additions and 325 deletions

View File

@@ -1,6 +1,6 @@
'use client'
import type { ClientValidate, FormFieldBase } from 'payload'
import type { FormFieldBase, PayloadRequest, RichTextFieldValidation } from 'payload'
import type { BaseEditor, BaseOperation } from 'slate'
import type { HistoryEditor } from 'slate-history'
import type { ReactEditor } from 'slate-react'
@@ -56,6 +56,7 @@ const RichTextField: React.FC<
placeholder?: string
plugins: RichTextPlugin[]
richTextComponentMap: Map<string, React.ReactNode>
validate?: RichTextFieldValidation
width?: string
} & FormFieldBase
> = (props) => {
@@ -88,14 +89,14 @@ const RichTextField: React.FC<
const drawerDepth = useEditDepth()
const drawerIsOpen = drawerDepth > 1
const memoizedValidate: ClientValidate = useCallback(
const memoizedValidate = useCallback(
(value, validationOptions) => {
if (typeof validate === 'function') {
return validate(value, {
...validationOptions,
req: {
t: i18n.t,
},
} as PayloadRequest,
required,
})
}