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:
Shahed Nasser
2024-06-09 15:18:29 +02:00
committed by GitHub
parent 3f661c917b
commit e472aed00f
17 changed files with 958 additions and 265 deletions
@@ -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 doesnt handle authentication methods or store a users password. For that, youd 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 doesnt 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,
})
}
```