mirror of
https://github.com/supabase/supabase.git
synced 2026-07-05 07:14:28 +08:00
114 lines
1.9 KiB
Plaintext
114 lines
1.9 KiB
Plaintext
---
|
|
id: reset-password-email
|
|
title: "Reset Password (Email)"
|
|
slug: reset-password-email
|
|
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/dart.yml
|
|
---
|
|
|
|
import Tabs from '@theme/Tabs';
|
|
import TabsPanel from '@theme/TabsPanel';
|
|
|
|
Sends a reset request to an email address.
|
|
|
|
|
|
<Tabs
|
|
defaultActiveId="dart"
|
|
groupId="reference/dart"
|
|
values={[{ label: 'Dart', value: 'dart' }]}>
|
|
|
|
<TabsPanel id="dart" label="dart">
|
|
|
|
```dart
|
|
final res = await supabase.auth.api.resetPasswordForEmail('user@example.com');
|
|
|
|
final error = res.error;
|
|
```
|
|
|
|
|
|
</TabsPanel>
|
|
|
|
</Tabs>
|
|
|
|
|
|
|
|
|
|
|
|
## 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
|
|
|
|
|
|
|
|
<Tabs
|
|
defaultActiveId="dart"
|
|
groupId="reference/dart"
|
|
values={[{ label: 'Dart', value: 'dart' }]}>
|
|
|
|
<TabsPanel id="dart" label="dart">
|
|
|
|
```dart
|
|
final res = await supabase.auth.api.resetPasswordForEmail('user@example.com');
|
|
|
|
final error = res.error;
|
|
```
|
|
|
|
|
|
</TabsPanel>
|
|
|
|
</Tabs>
|
|
|
|
### Reset password for Flutter
|
|
|
|
|
|
|
|
<Tabs
|
|
defaultActiveId="dart"
|
|
groupId="reference/dart"
|
|
values={[{ label: 'Dart', value: 'dart' }]}>
|
|
|
|
<TabsPanel id="dart" label="dart">
|
|
|
|
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;
|
|
```
|
|
|
|
|
|
</TabsPanel>
|
|
|
|
</Tabs> |