Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Update v1 docs

dannykng41c87699a4cc
diff --git a/spec/supabase_js_v1_legacy.yml b/spec/supabase_js_v1_legacy.yml
index c5358848c23..b2410601056 100644
--- a/spec/supabase_js_v1_legacy.yml
+++ b/spec/supabase_js_v1_legacy.yml
@@ -592,26 +592,41 @@ pages:
$ref: '@supabase/gotrue-js.GoTrueApi.resetPasswordForEmail'
notes: |
Sends a reset request to an email address.
-
- When the user clicks the reset link in the email they will be forwarded to:
-
- `<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:
-
+ When the user clicks the reset link in the email they are redirected back to your application.
+ Prompt the user for a new password and call `auth.update()`:
```js
- const { error, data } = await supabase.auth.api
- .updateUser(access_token, { password : new_password })
+ const { data, error } = await supabase.auth
+ .update({ password: new_password })
```
examples:
- - name: Reset password
+ - name: Reset password (React)
isSpotlight: true
js: |
```js
- const { data, error } = await supabase.auth.api
+ /**
+ * Step 1: Send the user an email to get a password reset token.
+ * This email contains a link which sends the user back to your application.
+ */
+ const { data, error } = await supabase.auth
.resetPasswordForEmail('[email protected]')
+
+ /**
+ * Step 2: Once the user is redirected back to your application,
+ * ask the user to reset their password.
+ */
+ useEffect(() => {
+ supabase.auth.onAuthStateChange(async (event, session) => {
+ if (event == "PASSWORD_RECOVERY") {
+ const newPassword = prompt("What would you like your new password to be?");
+ const { data, error } = await supabase
+ .auth
+ .update({ password: newPassword })
+
+ if (data) alert("Password updated successfully!")
+ if (error) alert("There was an error updating your password.")
+ }
+ })
+ }, [])
```
auth.api.generateLink():