docs: new + improved auth documentation pages (#7529)
* added and improved auth docs * add prep to generates resources action * add module options to sidebar * fix broken link
This commit is contained in:
@@ -6,14 +6,6 @@ export const metadata = {
|
||||
|
||||
This document provides flows to create a user.
|
||||
|
||||
## Using the Auth Module
|
||||
|
||||
The Auth Module allows you to create a user with different providers, such as creating a user with an email and password or creating a user using their Google account.
|
||||
|
||||
Learn more about this creation flow in [this Auth Module guide](../../auth/user-creation/page.mdx).
|
||||
|
||||
---
|
||||
|
||||
## Invite Users
|
||||
|
||||
Another possible flow to create a user is by sending them an invite. Then, once they accept it, you create a new user for them:
|
||||
@@ -58,4 +50,26 @@ const user = await userModuleService.create({
|
||||
})
|
||||
```
|
||||
|
||||
However, the User Module doesn’t handle authentication methods or store a user’s password. For that, you’d need to use the [Auth Module](../../auth/page.mdx).
|
||||
### With the Auth Module
|
||||
|
||||
By combining the User and Auth Modules, you can use the Auth Module for authenticating users, and the User Module to manage those users.
|
||||
|
||||
So, when a user is authenticated, and you receive the `AuthIdentity` object, you can use it to create a user if it doesn’t exist:
|
||||
|
||||
```ts
|
||||
const { success, authIdentity } =
|
||||
await authModuleService.authenticate("emailpass", {
|
||||
// ...
|
||||
})
|
||||
|
||||
// assuming authIdentity is defined
|
||||
const [, count] = await userModuleService.listAndCount({
|
||||
email: authIdentity.entity_id,
|
||||
})
|
||||
|
||||
if (!count) {
|
||||
const user = await userModuleService.create({
|
||||
email: authIdentity.entity_id,
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user