docs: Add callbacks example for Credential Provider

This commit is contained in:
Thang Vu
2023-09-02 09:40:31 +07:00
parent f621627914
commit f1eb45f3c1
2 changed files with 25 additions and 1 deletions

View File

@@ -69,7 +69,18 @@ providers: [
...
```
See the [callbacks documentation](/reference/configuration/auth-config#callbacks) for more information on how to interact with the token.
See the [callbacks documentation](/reference/configuration/auth-config#callbacks) for more information on how to interact with the token. For example, you can add additional information to the token by returning an object from the `jwt()` callback:
```js
callbacks: {
async jwt(token, user, account, profile, isNewUser) {
if (user) {
token.id = user.id
}
return token
}
}
```
## Example - Web3 / Signin With Ethereum

View File

@@ -77,6 +77,19 @@ export type CredentialsProviderType = "Credentials"
* with supporting usernames and passwords.
*
* :::
*
* See the [callbacks documentation](/reference/configuration/auth-config#callbacks) for more information on how to interact with the token. For example, you can add additional information to the token by returning an object from the `jwt()` callback:
*
* ```js
* callbacks: {
* async jwt(token, user, account, profile, isNewUser) {
* if (user) {
* token.id = user.id
* }
* return token
* }
* }
* ```
*
* @example
* ```js