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/end-user-flows/one-time-token.mdx
+54-2Lines changed: 54 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,7 @@ Logto supports the following scenarios with magic links:
18
18
-**Invitation-only registration**: For internal tools or AI products in testing phase, you can disable public registration and invite specific users via magic links.
19
19
-**Organization member invitation**: For SaaS products, use magic links to invite new members to join an organization, streamlining the onboarding process.
20
20
-**Sign-in / Sign-up**: Send a magic link for passwordless sign-in or sign-up via email.
21
+
-**Password reset**: Send a reset-password magic link from your own application so the user can verify the one-time token and set a new password in Logto.
21
22
22
23
For example, when you've disabled public registration, you can send a magic link with a one-time token (e.g., `https://yourapp.com/landing-page?token=YHwbXSXxQfL02IoxFqr1hGvkB13uTqcd&email=user@example.com`) to the user's email to invite them to complete account creation. You can customize the email template in your own email delivery service, such as:
23
24
@@ -28,7 +29,6 @@ For example, when you've disabled public registration, you can send a magic link
28
29
29
30
Currently not supported:
30
31
31
-
- Password reset with magic link.
32
32
- Using phone number or username as the identifier.
33
33
34
34
## One-time token flow \{#one-time-token-flow}
@@ -80,10 +80,24 @@ Sample request body payload:
80
80
}
81
81
```
82
82
83
+
For a password reset magic link, restrict the token to the forgot password flow:
84
+
85
+
```json
86
+
{
87
+
"email": "user@example.com",
88
+
"expiresIn": 3600,
89
+
"context": {
90
+
"interactionEvent": "ForgotPassword"
91
+
}
92
+
}
93
+
```
94
+
83
95
### Step 2: Compose your magic link \{#step-2-compose-your-magic-link}
84
96
85
97
After you get the one-time token, you can compose a magic link and send it to the end user's email address.
86
-
The magic link should at least contain the token and the user email as parameters, and should navigate to a landing page in your own application.
98
+
For sign-in or sign-up magic links, the magic link should at least contain the token and the user email as parameters.
99
+
For password reset magic links, the email parameter is optional; if you omit it, Logto will ask the user to enter their email address before verifying the one-time token.
100
+
The magic link should navigate to a landing page in your own application.
87
101
E.g. `https://yourapp.com/landing-page`.
88
102
89
103
Here's a simple example of what the magic link may look like:
@@ -102,6 +116,8 @@ as well as encoding all the URL parameters.
102
116
103
117
### Step 3: Trigger the authentication flow via Logto SDK \{#step-3-trigger-the-authentication-flow-via-logto-sdk}
104
118
119
+
#### Sign-in or sign-up \{#sign-in-or-sign-up}
120
+
105
121
After the end user clicks the magic link and navigated to your application, you can extract the `token` and `email` parameters from the URL, and then call the `signIn()` function from Logto SDK to trigger the auth flow.
For password reset magic links, start an authentication request with `first_screen` set to `reset_password`.
160
+
Pass the one-time token through `one_time_token`.
161
+
If you already have the user's email from your landing page, pass it through `login_hint`; otherwise, omit `login_hint` and Logto will ask the user to enter their email address before token verification.
If a user is already signed-in, calling the`signIn()` function from SDK will automatically clear all cached tokens (ID token, access token, and refresh token) from client storage,
Copy file name to clipboardExpand all lines: docs/end-user-flows/sign-up-and-sign-in/reset-password.mdx
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -95,6 +95,10 @@ You can implement your own password reset flow by using the Logto's **Management
95
95
96
96
</summary>
97
97
98
-
You can create a self-hosted password reset endpoint and utilize the Logto SDK to initiate a sign-in request with [`first_screen`](/end-user-flows/authentication-parameters/first-screen) set to `reset-password`. This will seamlessly redirect the user to the password reset page.
98
+
You can create a self-hosted password reset endpoint and use the Logto SDK to initiate a sign-in request with [`first_screen`](/end-user-flows/authentication-parameters/first-screen) set to `reset_password`. This redirects the user to the password reset page.
99
+
100
+
To verify the user with a magic link, create a [one-time token](/end-user-flows/one-time-token) for the user's email and pass it through the `one_time_token` authentication parameter. If you include `login_hint`, Logto will verify the token immediately; otherwise, Logto will ask the user to enter their email address before token verification.
101
+
102
+
Learn more in the [one-time token password reset guide](/end-user-flows/one-time-token#reset-password).
0 commit comments