2FA
This commit is contained in:
parent
7f05a3cbaf
commit
aa4c5e6593
|
|
@ -90,8 +90,8 @@ class SaveUserSettingsFailure implements StopSaving {
|
|||
|
||||
class SaveAuthUserRequest implements StartSaving {
|
||||
SaveAuthUserRequest({
|
||||
@required this.completer,
|
||||
@required this.user,
|
||||
this.completer,
|
||||
this.password,
|
||||
this.idToken,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -106,14 +106,18 @@ Middleware<AppState> _saveAuthUser(SettingsRepository settingsRepository) {
|
|||
.then((user) {
|
||||
store.dispatch(SaveAuthUserSuccess(user));
|
||||
store.dispatch(UserVerifiedPassword());
|
||||
action.completer.complete();
|
||||
if (action.completer != null) {
|
||||
action.completer.complete();
|
||||
}
|
||||
}).catchError((Object error) {
|
||||
print(error);
|
||||
store.dispatch(SaveAuthUserFailure(error));
|
||||
if ('$error'.contains('412')) {
|
||||
store.dispatch(UserUnverifiedPassword());
|
||||
}
|
||||
action.completer.completeError(error);
|
||||
if (action.completer != null) {
|
||||
action.completer.completeError(error);
|
||||
}
|
||||
});
|
||||
|
||||
next(action);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import 'package:flutter/foundation.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
import 'package:invoiceninja_flutter/constants.dart';
|
||||
import 'package:invoiceninja_flutter/data/models/user_model.dart';
|
||||
import 'package:invoiceninja_flutter/data/web_client.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||
import 'package:invoiceninja_flutter/redux/settings/settings_actions.dart';
|
||||
|
|
@ -13,7 +12,6 @@ import 'package:invoiceninja_flutter/ui/app/forms/app_form.dart';
|
|||
import 'package:invoiceninja_flutter/ui/app/forms/color_picker.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/forms/decorated_form_field.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/edit_scaffold.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/forms/learn_more.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/forms/notification_settings.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/forms/password_field.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/loading_indicator.dart';
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ class UserDetailsVM {
|
|||
@required this.state,
|
||||
@required this.onChanged,
|
||||
@required this.onSavePressed,
|
||||
@required this.onDisconnectGooglePressed,
|
||||
@required this.onDisableTwoFactorPressed,
|
||||
});
|
||||
|
||||
static UserDetailsVM fromStore(Store<AppState> store) {
|
||||
|
|
@ -44,6 +46,32 @@ class UserDetailsVM {
|
|||
state: state,
|
||||
user: state.uiState.settingsUIState.user,
|
||||
onChanged: (user) => store.dispatch(UpdateUserSettings(user: user)),
|
||||
onDisableTwoFactorPressed: (context) {
|
||||
passwordCallback(
|
||||
context: context,
|
||||
callback: (password, idToken) {
|
||||
store.dispatch(
|
||||
SaveAuthUserRequest(
|
||||
//user: state.user.rebuild((b) => b..oauthProvider = ''),
|
||||
password: password,
|
||||
idToken: idToken,
|
||||
),
|
||||
);
|
||||
});
|
||||
},
|
||||
onDisconnectGooglePressed: (context) {
|
||||
passwordCallback(
|
||||
context: context,
|
||||
callback: (password, idToken) {
|
||||
store.dispatch(
|
||||
SaveAuthUserRequest(
|
||||
user: state.user.rebuild((b) => b..oauthProvider = ''),
|
||||
password: password,
|
||||
idToken: idToken,
|
||||
),
|
||||
);
|
||||
});
|
||||
},
|
||||
onSavePressed: (context) {
|
||||
final completer = snackBarCompleter<Null>(
|
||||
context, AppLocalization.of(context).savedSettings);
|
||||
|
|
@ -70,4 +98,6 @@ class UserDetailsVM {
|
|||
final UserEntity user;
|
||||
final Function(UserEntity) onChanged;
|
||||
final Function(BuildContext) onSavePressed;
|
||||
final Function(BuildContext) onDisconnectGooglePressed;
|
||||
final Function(BuildContext) onDisableTwoFactorPressed;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue