Skip to content

Commit 6c6335f

Browse files
committed
implement reset password on the web
1 parent 3451fd7 commit 6c6335f

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

lib/src/web/gigya_flutter_plugin_web.dart

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ import 'static_interop/models/profile.dart';
1414
import 'static_interop/parameters/basic.dart';
1515
import 'static_interop/parameters/login.dart';
1616
import 'static_interop/parameters/registration.dart';
17+
import 'static_interop/parameters/reset_password.dart';
1718
import 'static_interop/response/registration_response.dart';
19+
import 'static_interop/response/reset_password_response.dart';
1820
import 'static_interop/response/response.dart';
1921
import 'static_interop/window.dart';
2022
import 'web_account_delegate.dart';
@@ -76,6 +78,41 @@ class GigyaFlutterPluginWeb extends GigyaFlutterPluginPlatform {
7678
return completer.future;
7779
}
7880

81+
@override
82+
Future<Map<String, dynamic>> forgotPassword(
83+
String loginId, {
84+
Map<String, dynamic> parameters = const <String, dynamic>{},
85+
}) async {
86+
final String? passwordResetToken = parameters['passwordResetToken'] as String?;
87+
final String? newPassword = parameters['newPassword'] as String?;
88+
89+
// Either login id or password reset token is required.
90+
if (loginId.isNotEmpty && passwordResetToken != null) {
91+
throw ArgumentError('Either loginId or passwordResetToken should be specified.');
92+
}
93+
94+
// If the password reset token is present, the new password should also be present.
95+
if (passwordResetToken != null && newPassword == null) {
96+
throw ArgumentError.notNull('newPassword');
97+
}
98+
99+
final ResetPasswordResponse response = gigyaWebSdk.accounts.resetPassword(
100+
ResetPasswordParameters(
101+
email: parameters['email'] as String?,
102+
ignoreInterruptions: parameters['ignoreInterruptions'] as bool? ?? false,
103+
lang: parameters['lang'] as String?,
104+
// Treat an empty login id as null.
105+
loginID: loginId.isEmpty ? null : loginId,
106+
newPassword: newPassword,
107+
passwordResetToken: passwordResetToken,
108+
secretAnswer: parameters['secretAnswer'] as String?,
109+
securityFields: parameters['securityFields'] as String?,
110+
),
111+
);
112+
113+
return StaticInteropUtils.responseToMap(response);
114+
}
115+
79116
@override
80117
Future<String> initRegistration({required bool isLite}) {
81118
final Completer<String> initRegistrationCompleter = Completer<String>();

0 commit comments

Comments
 (0)