@@ -50,7 +50,7 @@ class GoTrueAdminApi {
50
50
///
51
51
/// This function should only be called on a server. Never expose your `service_role` key on the client.
52
52
///
53
- // Requires either an email or phone
53
+ /// Requires either an email or phone
54
54
Future <UserResponse > createUser (AdminUserAttributes attributes) async {
55
55
final options = GotrueRequestOptions (
56
56
headers: _headers,
@@ -121,19 +121,41 @@ class GoTrueAdminApi {
121
121
}
122
122
123
123
/// Generates links to be sent via email or other.
124
+ ///
125
+ /// [password] is required for [GenerateLinkType.signup]
126
+ ///
127
+ /// [newEmail] is required for [GenerateLinkType.emailChangeCurrent]
128
+ /// and [GenerateLinkType.emailChangeNew]
129
+ ///
130
+ /// [data] may be used to store the user's metadata.
131
+ /// This maps to the `auth.users.user_metadata` column.
132
+ /// Applicable for [GenerateLinkType.signup] , [GenerateLinkType.invite] ,
133
+ /// [GenerateLinkType.magiclink]
124
134
Future <GenerateLinkResponse > generateLink ({
125
135
required GenerateLinkType type,
126
136
required String email,
137
+ String ? newEmail,
127
138
String ? password,
128
139
Map <String , dynamic >? data,
129
140
String ? redirectTo,
130
141
}) async {
142
+ assert (
143
+ ! (type == GenerateLinkType .emailChangeCurrent ||
144
+ type == GenerateLinkType .emailChangeNew) ||
145
+ newEmail != null ,
146
+ 'newEmail is required for emailChangeCurrent and emailChangeNew' ,
147
+ );
148
+ assert (
149
+ type != GenerateLinkType .signup || password != null ,
150
+ 'password is required for signup' ,
151
+ );
131
152
final body = {
132
153
'email' : email,
133
154
'type' : type.snakeCase,
134
155
if (data != null ) 'data' : data,
135
156
if (redirectTo != null ) 'redirect_to' : redirectTo,
136
157
if (password != null ) 'password' : password,
158
+ if (newEmail != null ) 'new_email' : newEmail,
137
159
};
138
160
139
161
final fetchOptions = GotrueRequestOptions (headers: _headers, body: body);
0 commit comments