resetPasswordForEmail method
Sends a reset request to an email address.
Implementation
Future<GotrueJsonResponse> resetPasswordForEmail(
String email, {
AuthOptions? options,
}) async {
try {
final body = {'email': email};
final fetchOptions = FetchOptions(headers);
final urlParams = [];
if (options?.redirectTo != null) {
final encodedRedirectTo = Uri.encodeComponent(options!.redirectTo!);
urlParams.add('redirect_to=$encodedRedirectTo');
}
final queryString = urlParams.isNotEmpty ? '?${urlParams.join('&')}' : '';
final response = await _fetch.post(
'$url/recover$queryString',
body,
options: fetchOptions,
);
if (response.error != null) {
return GotrueJsonResponse.fromResponse(response: response);
} else {
return GotrueJsonResponse.fromResponse(
response: response,
data: response.rawData as Map<String, dynamic>?,
);
}
} catch (e) {
return GotrueJsonResponse(error: GotrueError(e.toString()));
}
}