feat: ability to login with email, username or both (#7086)
`auth.loginWithUsername`:
```ts
auth: {
loginWithUsername: {
allowEmailLogin: true, // default: false
requireEmail: false, // default: false
}
}
```
#### `allowEmailLogin`
This property will allow you to determine if users should be able to
login with either email or username. If set to `false`, the default
value, then users will only be able to login with usernames when using
the `loginWithUsername` property.
#### `requireEmail`
Require that users also provide emails when using usernames.
This commit is contained in:
@@ -207,6 +207,6 @@ export interface Auth {
|
||||
|
||||
|
||||
declare module 'payload' {
|
||||
// @ts-ignore
|
||||
// @ts-ignore
|
||||
export interface GeneratedTypes extends Config {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,21 +98,21 @@ export class NextRESTClient {
|
||||
const url = `${this.serverURL}${this.config.routes.api}/${slugs}`
|
||||
|
||||
return {
|
||||
url,
|
||||
slug: slugs.split('/'),
|
||||
params: params ? qs.parse(params) : undefined,
|
||||
url,
|
||||
}
|
||||
}
|
||||
|
||||
async DELETE(path: ValidPath, options: RequestInit & RequestOptions = {}): Promise<Response> {
|
||||
const { url, slug, params } = this.generateRequestParts(path)
|
||||
const { slug, params, url } = this.generateRequestParts(path)
|
||||
const { query, ...rest } = options || {}
|
||||
const queryParams = generateQueryString(query, params)
|
||||
|
||||
const request = new Request(`${url}${queryParams}`, {
|
||||
...rest,
|
||||
method: 'DELETE',
|
||||
headers: this.buildHeaders(options),
|
||||
method: 'DELETE',
|
||||
})
|
||||
return this._DELETE(request, { params: { slug } })
|
||||
}
|
||||
@@ -121,14 +121,14 @@ export class NextRESTClient {
|
||||
path: ValidPath,
|
||||
options: Omit<RequestInit, 'body'> & RequestOptions = {},
|
||||
): Promise<Response> {
|
||||
const { url, slug, params } = this.generateRequestParts(path)
|
||||
const { slug, params, url } = this.generateRequestParts(path)
|
||||
const { query, ...rest } = options || {}
|
||||
const queryParams = generateQueryString(query, params)
|
||||
|
||||
const request = new Request(`${url}${queryParams}`, {
|
||||
...rest,
|
||||
method: 'GET',
|
||||
headers: this.buildHeaders(options),
|
||||
method: 'GET',
|
||||
})
|
||||
return this._GET(request, { params: { slug } })
|
||||
}
|
||||
@@ -140,8 +140,8 @@ export class NextRESTClient {
|
||||
`${this.serverURL}${this.config.routes.api}${this.config.routes.graphQL}${queryParams}`,
|
||||
{
|
||||
...rest,
|
||||
method: 'POST',
|
||||
headers: this.buildHeaders(options),
|
||||
method: 'POST',
|
||||
},
|
||||
)
|
||||
return this._GRAPHQL_POST(request)
|
||||
@@ -154,8 +154,8 @@ export class NextRESTClient {
|
||||
|
||||
const request = new Request(`${url}${queryParams}`, {
|
||||
...rest,
|
||||
method: 'PATCH',
|
||||
headers: this.buildHeaders(options),
|
||||
method: 'PATCH',
|
||||
})
|
||||
return this._PATCH(request, { params: { slug } })
|
||||
}
|
||||
@@ -164,12 +164,12 @@ export class NextRESTClient {
|
||||
path: ValidPath,
|
||||
options: FileArg & RequestInit & RequestOptions = {},
|
||||
): Promise<Response> {
|
||||
const { url, slug, params } = this.generateRequestParts(path)
|
||||
const { slug, params, url } = this.generateRequestParts(path)
|
||||
const queryParams = generateQueryString({}, params)
|
||||
const request = new Request(`${url}${queryParams}`, {
|
||||
...options,
|
||||
method: 'POST',
|
||||
headers: this.buildHeaders(options),
|
||||
method: 'POST',
|
||||
})
|
||||
return this._POST(request, { params: { slug } })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user