This commit is contained in:
Hillel Coren 2019-11-04 13:55:51 +02:00
parent dfcb8b6224
commit 241001d51b
4 changed files with 26 additions and 1 deletions

View File

@ -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);

View File

@ -217,9 +217,11 @@ Middleware<AppState> _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);
}
});

View File

@ -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<LoginView> {
completer.future.then((_) {
setState(() {
_loginError = '';
if (_recovePassword) {
_recovePassword = false;
showDialog<MessageDialog>(
context: context,
builder: (BuildContext context) {
return MessageDialog(
AppLocalization.of(context).recoverPasswordEmailSent);
});
}
});
}).catchError((Object error) {
setState(() {

View File

@ -14,6 +14,7 @@ abstract class LocaleCodeAware {
mixin LocalizationsProvider on LocaleCodeAware {
static final Map<String, Map<String, String>> _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] ??