Skip to content

Commit 645c481

Browse files
committed
convert the usage of forgotPassword to extension types
1 parent e7a640b commit 645c481

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed

lib/src/web/gigya_flutter_plugin_web.dart

+8-18
Original file line numberDiff line numberDiff line change
@@ -80,34 +80,24 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform {
8080
String loginId, {
8181
Map<String, dynamic> parameters = const <String, dynamic>{},
8282
}) async {
83-
final String? passwordResetToken = parameters['passwordResetToken'] as String?;
84-
final String? newPassword = parameters['newPassword'] as String?;
85-
86-
// Either login id or password reset token is required.
87-
if (loginId.isNotEmpty && passwordResetToken != null) {
88-
throw ArgumentError('Either loginId or passwordResetToken should be specified.');
89-
}
90-
91-
// If the password reset token is present, the new password should also be present.
92-
if (passwordResetToken != null && newPassword == null) {
93-
throw ArgumentError.notNull('newPassword');
94-
}
95-
96-
final ResetPasswordResponse response = gigyaWebSdk.accounts.resetPassword(
83+
final JSAny? response = GigyaWebSdk.instance.accounts.resetPassword.callAsFunction(
84+
null,
9785
ResetPasswordParameters(
9886
email: parameters['email'] as String?,
99-
ignoreInterruptions: parameters['ignoreInterruptions'] as bool? ?? false,
87+
ignoreInterruptions: parameters['ignoreInterruptions'] as bool?,
10088
lang: parameters['lang'] as String?,
10189
// Treat an empty login id as null.
10290
loginID: loginId.isEmpty ? null : loginId,
103-
newPassword: newPassword,
104-
passwordResetToken: passwordResetToken,
91+
newPassword: parameters['newPassword'] as String?,
92+
passwordResetToken: parameters['passwordResetToken'] as String?,
10593
secretAnswer: parameters['secretAnswer'] as String?,
10694
securityFields: parameters['securityFields'] as String?,
95+
sendEmail: parameters['sendEmail'] as bool?,
10796
),
10897
);
10998

110-
return StaticInteropUtils.responseToMap(response);
99+
// TODO: `callAsFunction` does not yet support generics.
100+
return (response as ResetPasswordResponse).toMap();
111101
}
112102

113103
@override

lib/src/web/static_interop/response/reset_password_response.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ extension type ResetPasswordResponse(Response baseResponse) {
4141
'secretQuestion': secretQuestion,
4242
'UID': UID,
4343
};
44-
}
44+
}
4545
}

0 commit comments

Comments
 (0)