docs: update docs on change email

This commit is contained in:
Bereket Engida
2024-10-18 20:13:29 +03:00
parent 0b66552299
commit 897a5439b2
3 changed files with 21 additions and 30 deletions

View File

@@ -33,7 +33,7 @@ await authClient.user.update({
### Change Email
To change the email of a user, you can use the `changeEmail` function provided by the client. The `changeEmail` function take a `newEmail` as argument. The `password` is used to verify the user. Before the email is changed, the user is required to verify the new email.
To change the email of a user, you can use the `changeEmail` function provided by the client. The `changeEmail` function take a `newEmail` as argument. Before the email is changed, the user is required to verify their existing email.
```ts
await authClient.user.changeEmail({
@@ -42,7 +42,7 @@ await authClient.user.changeEmail({
});
```
after the email is changed, the user is required to verify the new email. So a verification email is sent to the new email. Once the email is verified, the email is updated in the user table. If you want to disable this behavior, you can set `sendVerificationEmail` to `false`.
after they verify their email, the new email is updated in the user table. And the user is required to verify the new email. So a verification email is sent to the new email. Once the email is verified, the email is updated in the user table. If you want to disable this behavior, you can set `sendVerificationEmail` to `false`.
**Disable Email verification**
@@ -55,33 +55,8 @@ export const auth = betterAuth({
}
})
```
To change a user's email, the `changeEmail` function is available through the client. It takes `newEmail` and `password` as parameters, where the `password` is used to verify the user. A verification email is sent to the new email, and the email is updated in the user table after verification.
```ts
await authClient.user.changeEmail({
newEmail: "new-email@email.com",
password: "password123",
callbackURL: "/dashboard", // optional: redirect the user after verification
});
```
By default, a verification email is required for the change to take effect. You can disable this by setting `sendVerificationEmail` to `false`.
### Disable Email Verification
To skip the email verification step:
```ts
export const auth = betterAuth({
user: {
changeEmail: {
sendVerificationEmail: false,
}
}
});
```
### Disable Change Email Feature
**Disable Change Email Feature**
To disable the ability for users to change their email: