mirror of
https://github.com/SrIzan10/next-auth.git
synced 2026-05-01 10:55:20 +00:00
docs: Add callbacks example for Credential Provider
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user