Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add newEmail to admin generateLink method #904

Merged
merged 2 commits into from
Apr 26, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion packages/gotrue/lib/src/gotrue_admin_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class GoTrueAdminApi {
///
/// This function should only be called on a server. Never expose your `service_role` key on the client.
///
// Requires either an email or phone
/// Requires either an email or phone
Future<UserResponse> createUser(AdminUserAttributes attributes) async {
final options = GotrueRequestOptions(
headers: _headers,
Expand Down Expand Up @@ -121,9 +121,20 @@ class GoTrueAdminApi {
}

/// Generates links to be sent via email or other.
///
/// [password] is used for [GenerateLinkType.signup]
///
/// [newEmail] is used for [GenerateLinkType.emailChangeCurrent]
/// and [GenerateLinkType.emailChangeNew]
bdlukaa marked this conversation as resolved.
Show resolved Hide resolved
///
/// [data] may be used to store the user's metadata.
/// This maps to the `auth.users.user_metadata` column.
/// Applicable for [GenerateLinkType.signup], [GenerateLinkType.invite],
/// [GenerateLinkType.magiclink]
Future<GenerateLinkResponse> generateLink({
required GenerateLinkType type,
required String email,
String? newEmail,
String? password,
Map<String, dynamic>? data,
String? redirectTo,
Expand All @@ -134,6 +145,7 @@ class GoTrueAdminApi {
if (data != null) 'data': data,
if (redirectTo != null) 'redirect_to': redirectTo,
if (password != null) 'password': password,
if (newEmail != null) 'new_email': newEmail,
};

final fetchOptions = GotrueRequestOptions(headers: _headers, body: body);
Expand Down
Loading