You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/docs/plugins/email-otp.mdx
+25-12Lines changed: 25 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ title: Email OTP
3
3
description: Email OTP plugin for Better Auth.
4
4
---
5
5
6
-
The Email OTP plugin allows user to sign-in and verify their email using a one-time password (OTP) sent to their email address.
6
+
The Email OTP plugin allows user to sign-in, verify their email, or reset their password using a one-time password (OTP) sent to their email address.
7
7
8
8
9
9
## Installation
@@ -50,12 +50,12 @@ The Email OTP plugin allows user to sign-in and verify their email using a one-t
50
50
51
51
### Send OTP
52
52
53
-
Before signing in or verifying email, you need to send an OTP to the user's email address.
53
+
First, send an OTP to the user's email address.
54
54
55
55
```ts title="example.ts"
56
56
awaitauthClient.emailOtp.sendVerificationOtp({
57
57
email: "user-email@email.com",
58
-
type: "sign-in"// or "email-verification"
58
+
type: "sign-in"// or "email-verification", "forget-password"
59
59
})
60
60
```
61
61
@@ -70,8 +70,7 @@ const user = await authClient.signIn.emailOtp({
70
70
})
71
71
```
72
72
73
-
If the user is not registered, it'll be automatically registered. If you want to prevent this, you can pass `disableSignUp` as `true` in the options.
74
-
73
+
If the user is not registered, they'll be automatically registered. If you want to prevent this, you can pass `disableSignUp` as `true` in the options.
75
74
76
75
### Verify Email
77
76
@@ -84,12 +83,24 @@ const user = await authClient.emailOtp.verifyEmail({
84
83
})
85
84
```
86
85
86
+
### Reset Password
87
+
88
+
To reset the user's password, use the `resetPassword()` method.
89
+
90
+
```ts title="example.ts"
91
+
awaitauthClient.emailOtp.resetPassword({
92
+
email: "user-email@email.com",
93
+
otp: "123456",
94
+
password: "password"
95
+
})
96
+
```
97
+
87
98
## Options
88
99
89
100
-`sendVerificationOTP`: A function that sends the OTP to the user's email address. The function receives an object with the following properties:
90
101
-`email`: The user's email address.
91
102
-`otp`: The OTP to send.
92
-
-`type`: The type of OTP to send. Can be either "sign-in" or "email-verification".
103
+
-`type`: The type of OTP to send. Can be "sign-in", "email-verification", or "forget-password".
0 commit comments