Files
supabase/apps/reference/_supabase_dart/generated/reset-password-email.mdx

62 lines
1.4 KiB
Plaintext

---
id: reset-password-email
title: 'Reset Password (Email)'
slug: /reset-password-email
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Sends a reset request to an email address.
```dart
final res = await supabase.auth.api.resetPasswordForEmail('user@example.com');
final error = res.error;
```
## 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:
```dart
final res = await supabase.auth.api.updateUser(
accessToken,
UserAttributes(password: 'NEW_PASSWORD'),
);
```
## Examples
### Reset password
```dart
final res = await supabase.auth.api.resetPasswordForEmail('user@example.com');
final error = res.error;
```
### Reset password for Flutter
You can pass `redirectTo` to open the app via deeplink when user opens the password reset email.
```dart
final res = await supabase.auth.api.resetPasswordForEmail(
'user@example.com',
options: AuthOptions(redirectTo: kIsWeb
? null
: 'io.supabase.flutter://reset-callback/'),
);
final error = res.error;
```