docs: document registering user with existing email (#10859)
This commit is contained in:
@@ -53,7 +53,7 @@ This method calls the `authenticate` method of the provider specified in the fir
|
||||
The basic authentication flow requires first using the `register` method, then the `authenticate` method:
|
||||
|
||||
```ts
|
||||
const { success, authIdentity } = await authModuleService.register(
|
||||
const { success, authIdentity, error } = await authModuleService.register(
|
||||
"emailpass",
|
||||
// passed to auth provider
|
||||
{
|
||||
@@ -61,6 +61,12 @@ const { success, authIdentity } = await authModuleService.register(
|
||||
}
|
||||
)
|
||||
|
||||
if (error) {
|
||||
// registration failed
|
||||
// TODO return an error
|
||||
return
|
||||
}
|
||||
|
||||
// later (can be another route for log-in)
|
||||
const { success, authIdentity, location } = await authModuleService.authenticate(
|
||||
"emailpass",
|
||||
@@ -87,6 +93,15 @@ Check out the [AuthIdentity](/references/auth/models/AuthIdentity) reference for
|
||||
|
||||

|
||||
|
||||
### Auth Identity with Same Identifier
|
||||
|
||||
If an auth identity, such as a `customer`, tries to register with an email of another auth identity, the `register` method returns an error. This can happen either if another customer is using the same email, or an admin user has the same email.
|
||||
|
||||
There are two ways to handle this:
|
||||
|
||||
- Consider the customer authenticated if the `authenticate` method validates that the email and password are correct. This allows admin users, for example, to authenticate as customers.
|
||||
- Return an error message to the customer, informing them that the email is already in use.
|
||||
|
||||
---
|
||||
|
||||
## Auth Flow 2: Third-Party Service Authentication
|
||||
|
||||
Reference in New Issue
Block a user