Confirm email
This commit is contained in:
parent
bb7e05e9a4
commit
dff671a999
|
|
@ -161,6 +161,14 @@ class AuthRepository {
|
||||||
password: password);
|
password: password);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<dynamic> resendConfirmation(
|
||||||
|
{@required Credentials credentials, @required String userId}) async {
|
||||||
|
return webClient.post(
|
||||||
|
'${credentials.url}/user/$userId/reconfirm',
|
||||||
|
credentials.token,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Future<LoginResponse> sendRequest({
|
Future<LoginResponse> sendRequest({
|
||||||
String url,
|
String url,
|
||||||
dynamic data,
|
dynamic data,
|
||||||
|
|
|
||||||
|
|
@ -151,6 +151,15 @@ class LoadAccountSuccess implements StopLoading {
|
||||||
final LoginResponse loginResponse;
|
final LoginResponse loginResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ResendConfirmation implements StartLoading {}
|
||||||
|
|
||||||
|
class ResendConfirmationFailure implements StopLoading {
|
||||||
|
ResendConfirmationFailure(this.error);
|
||||||
|
final dynamic error;
|
||||||
|
}
|
||||||
|
|
||||||
|
class ResendConfirmationSuccess implements StopLoading {}
|
||||||
|
|
||||||
class RefreshData implements StartLoading {
|
class RefreshData implements StartLoading {
|
||||||
RefreshData({
|
RefreshData({
|
||||||
this.completer,
|
this.completer,
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ List<Middleware<AppState>> createStoreAuthMiddleware([
|
||||||
final addCompany = _createCompany(repository);
|
final addCompany = _createCompany(repository);
|
||||||
final deleteCompany = _deleteCompany(repository);
|
final deleteCompany = _deleteCompany(repository);
|
||||||
final purgeData = _purgeData(repository);
|
final purgeData = _purgeData(repository);
|
||||||
|
final resendConfirmation = _resendConfirmation(repository);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
TypedMiddleware<AppState, UserLogout>(userLogout),
|
TypedMiddleware<AppState, UserLogout>(userLogout),
|
||||||
|
|
@ -40,6 +41,7 @@ List<Middleware<AppState>> createStoreAuthMiddleware([
|
||||||
TypedMiddleware<AppState, AddCompany>(addCompany),
|
TypedMiddleware<AppState, AddCompany>(addCompany),
|
||||||
TypedMiddleware<AppState, DeleteCompanyRequest>(deleteCompany),
|
TypedMiddleware<AppState, DeleteCompanyRequest>(deleteCompany),
|
||||||
TypedMiddleware<AppState, PurgeDataRequest>(purgeData),
|
TypedMiddleware<AppState, PurgeDataRequest>(purgeData),
|
||||||
|
TypedMiddleware<AppState, ResendConfirmation>(resendConfirmation),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -371,6 +373,25 @@ Middleware<AppState> _purgeData(AuthRepository repository) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Middleware<AppState> _resendConfirmation(AuthRepository repository) {
|
||||||
|
return (Store<AppState> store, dynamic dynamicAction,
|
||||||
|
NextDispatcher next) async {
|
||||||
|
final action = dynamicAction as ResendConfirmation;
|
||||||
|
final state = store.state;
|
||||||
|
|
||||||
|
repository
|
||||||
|
.resendConfirmation(
|
||||||
|
credentials: state.credentials, userId: state.user.id)
|
||||||
|
.then((dynamic value) {
|
||||||
|
store.dispatch(ResendConfirmationSuccess());
|
||||||
|
}).catchError((Object error) {
|
||||||
|
store.dispatch(ResendConfirmationFailure(error));
|
||||||
|
});
|
||||||
|
|
||||||
|
next(action);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
String _parseError(String error) {
|
String _parseError(String error) {
|
||||||
const errorPattern = 'failed due to: Deserializing';
|
const errorPattern = 'failed due to: Deserializing';
|
||||||
if (error.contains(errorPattern)) {
|
if (error.contains(errorPattern)) {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:invoiceninja_flutter/constants.dart';
|
import 'package:invoiceninja_flutter/constants.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/app/buttons/elevated_button.dart';
|
|
||||||
import 'package:invoiceninja_flutter/ui/app/confirm_email_vm.dart';
|
import 'package:invoiceninja_flutter/ui/app/confirm_email_vm.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/app/loading_indicator.dart';
|
import 'package:invoiceninja_flutter/ui/app/loading_indicator.dart';
|
||||||
import 'package:invoiceninja_flutter/utils/localization.dart';
|
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ class ConfirmEmailVM {
|
||||||
store.dispatch(RefreshData());
|
store.dispatch(RefreshData());
|
||||||
},
|
},
|
||||||
onResendPressed: () {
|
onResendPressed: () {
|
||||||
//
|
store.dispatch(ResendConfirmation());
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue