mirror of
https://github.com/supabase/supabase.git
synced 2026-07-04 04:54:37 +08:00
92 lines
2.1 KiB
Plaintext
92 lines
2.1 KiB
Plaintext
---
|
|
id: auth-resetpasswordforemail
|
|
title: 'resetPasswordForEmail()'
|
|
slug: /auth-resetpasswordforemail
|
|
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_js_v2_legacy.yml
|
|
---
|
|
|
|
import Tabs from '@theme/Tabs'
|
|
import TabItem from '@theme/TabItem'
|
|
|
|
Sends a reset request to an email address.
|
|
|
|
```js
|
|
const { error, data } = await supabase.auth.resetPasswordForEmail(email, options: {
|
|
redirectTo: 'https://example.com/update-password',
|
|
})
|
|
```
|
|
|
|
## Parameters
|
|
|
|
<ul className="method-list-group">
|
|
|
|
<li className="method-list-item">
|
|
<h4 className="method-list-item-label">
|
|
<span className="method-list-item-label-name">
|
|
email
|
|
</span>
|
|
<span className="method-list-item-label-badge required">
|
|
required
|
|
</span>
|
|
<span className="method-list-item-validation">
|
|
<code>string</code>
|
|
</span>
|
|
</h4>
|
|
<div class="method-list-item-description">
|
|
|
|
The email address of the user.
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
<li className="method-list-item">
|
|
<h4 className="method-list-item-label">
|
|
<span className="method-list-item-label-name">
|
|
options
|
|
</span>
|
|
<span className="method-list-item-label-badge required">
|
|
required
|
|
</span>
|
|
<span className="method-list-item-validation">
|
|
<code>object</code>
|
|
</span>
|
|
</h4>
|
|
<div class="method-list-item-description">
|
|
|
|
No description provided.
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
## Notes
|
|
|
|
Sends a reset request to an email address.
|
|
|
|
When the user clicks the reset link in the email they will be forwarded to the site url or the redirect url specified:
|
|
|
|
`<SITE_URL>#access_token=x&refresh_token=y&expires_in=z&token_type=bearer&type=recovery`
|
|
|
|
Your app must detect `type=recovery` in the fragment and display a password reset form to the user.
|
|
|
|
You should then use the access_token in the url and new password to update the user as follows:
|
|
|
|
```js
|
|
const { error, data } = await supabase.auth.updateUser({
|
|
password: new_password,
|
|
})
|
|
```
|
|
|
|
## Examples
|
|
|
|
### Reset password
|
|
|
|
```js
|
|
const { error, data } = await supabase.auth.resetPasswordForEmail(email, options: {
|
|
redirectTo: 'https://example.com/update-password',
|
|
})
|
|
```
|