diff --git a/lib/redux/auth/auth_actions.dart b/lib/redux/auth/auth_actions.dart index b18fbd041..9f12225c6 100644 --- a/lib/redux/auth/auth_actions.dart +++ b/lib/redux/auth/auth_actions.dart @@ -83,6 +83,14 @@ class RecoverPasswordRequest implements StartLoading { final String secret; } +class RecoverPasswordSuccess implements StopLoading {} + +class RecoverPasswordFailure implements StopLoading { + RecoverPasswordFailure(this.error); + + final Object error; +} + class UserLogout implements PersistData, PersistUI { UserLogout(this.context); diff --git a/lib/redux/auth/auth_middleware.dart b/lib/redux/auth/auth_middleware.dart index 2edda7ea7..013951a4c 100644 --- a/lib/redux/auth/auth_middleware.dart +++ b/lib/redux/auth/auth_middleware.dart @@ -217,9 +217,11 @@ Middleware _createRecoverRequest(AuthRepository repository) { secret: action.secret, ) .then((data) { + store.dispatch(RecoverPasswordSuccess()); action.completer.complete(null); }).catchError((Object error) { if (action.completer != null) { + store.dispatch(RecoverPasswordFailure(error.toString())); action.completer.completeError(error); } }); diff --git a/lib/ui/auth/login_view.dart b/lib/ui/auth/login_view.dart index 2d51ae371..47a94782f 100644 --- a/lib/ui/auth/login_view.dart +++ b/lib/ui/auth/login_view.dart @@ -5,6 +5,7 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:invoiceninja_flutter/constants.dart'; import 'package:invoiceninja_flutter/redux/ui/ui_state.dart'; import 'package:invoiceninja_flutter/ui/app/buttons/elevated_button.dart'; +import 'package:invoiceninja_flutter/ui/app/dialogs/alert_dialog.dart'; import 'package:invoiceninja_flutter/ui/app/forms/decorated_form_field.dart'; import 'package:invoiceninja_flutter/ui/app/link_text.dart'; import 'package:invoiceninja_flutter/ui/app/loading_indicator.dart'; @@ -168,6 +169,15 @@ class _LoginState extends State { completer.future.then((_) { setState(() { _loginError = ''; + if (_recovePassword) { + _recovePassword = false; + showDialog( + context: context, + builder: (BuildContext context) { + return MessageDialog( + AppLocalization.of(context).recoverPasswordEmailSent); + }); + } }); }).catchError((Object error) { setState(() { diff --git a/lib/utils/i18n.dart b/lib/utils/i18n.dart index 14635987f..5a1367879 100644 --- a/lib/utils/i18n.dart +++ b/lib/utils/i18n.dart @@ -14,6 +14,7 @@ abstract class LocaleCodeAware { mixin LocalizationsProvider on LocaleCodeAware { static final Map> _localizedValues = { 'en': { + 'recover_password_email_sent': 'A password recovery email has been sent', 'submit': 'Submit', 'recover_password': 'Recover Password', 'late_fees': 'Late Fees', @@ -15452,10 +15453,14 @@ mixin LocalizationsProvider on LocaleCodeAware { String get lateFees => _localizedValues[localeCode]['late_fees']; - String get recoverPassword => _localizedValues[localeCode]['recover_password']; + String get recoverPassword => + _localizedValues[localeCode]['recover_password']; String get submit => _localizedValues[localeCode]['submit']; + String get recoverPasswordEmailSent => + _localizedValues[localeCode]['recover_password_email_sent']; + String lookup(String key) { final lookupKey = toSnakeCase(key); return _localizedValues[localeCode][lookupKey] ??