diff --git a/lib/data/repositories/auth_repository.dart b/lib/data/repositories/auth_repository.dart index 71ec78f5e..fff594c0b 100644 --- a/lib/data/repositories/auth_repository.dart +++ b/lib/data/repositories/auth_repository.dart @@ -15,11 +15,16 @@ class AuthRepository { final WebClient webClient; - Future signUp( - {String email, - String password, - String platform,}) async { + Future signUp({ + String firstName, + String lastName, + String email, + String password, + String platform, + }) async { final credentials = { + 'first_name': firstName, + 'last_name': lastName, 'token_name': 'invoice-ninja-$platform-app', 'api_secret': Config.API_SECRET, 'email': email, diff --git a/lib/redux/auth/auth_middleware.dart b/lib/redux/auth/auth_middleware.dart index 208c5ec97..551d9cbcc 100644 --- a/lib/redux/auth/auth_middleware.dart +++ b/lib/redux/auth/auth_middleware.dart @@ -121,6 +121,8 @@ Middleware _createSignUpRequest(AuthRepository repository) { email: action.email, password: action.password, platform: action.platform, + firstName: action.firstName, + lastName: action.lastName, ) .then((data) { _saveAuthLocal( diff --git a/lib/ui/auth/login_view.dart b/lib/ui/auth/login_view.dart index 056a91f9f..3fcec7fd9 100644 --- a/lib/ui/auth/login_view.dart +++ b/lib/ui/auth/login_view.dart @@ -202,11 +202,19 @@ class _LoginState extends State { DecoratedFormField( label: localization.firstName, controller: _firstNameController, + autovalidate: _autoValidate, + validator: (val) => val.isEmpty || val.trim().isEmpty + ? localization.pleaseEnterAFirstName + : null, ), if (_createAccount) DecoratedFormField( label: localization.lastName, controller: _lastNameController, + autovalidate: _autoValidate, + validator: (val) => val.isEmpty || val.trim().isEmpty + ? localization.pleaseEnterALastName + : null, ), TextFormField( controller: _emailController, diff --git a/lib/utils/i18n.dart b/lib/utils/i18n.dart index e970309c0..d921db978 100644 --- a/lib/utils/i18n.dart +++ b/lib/utils/i18n.dart @@ -14,6 +14,8 @@ abstract class LocaleCodeAware { mixin LocalizationsProvider on LocaleCodeAware { static final Map> _localizedValues = { 'en': { + 'please_enter_a_first_name': 'Please enter a first name', + 'please_enter_a_last_name': 'Please enter a last name', 'please_agree_to_terms_and_privacy' : 'Please agree to the terms of service and privacy policy to create an account.', 'i_agree_to_the': 'I agree to the', @@ -13148,6 +13150,12 @@ mixin LocalizationsProvider on LocaleCodeAware { String get pleaseEnterAProductKey => _localizedValues[localeCode]['please_enter_a_product_key']; + String get pleaseEnterAFirstName => + _localizedValues[localeCode]['please_enter_a_last_name']; + + String get pleaseEnterALastName => + _localizedValues[localeCode]['please_enter_a_first_name']; + String get ascending => _localizedValues[localeCode]['ascending']; String get descending => _localizedValues[localeCode]['descending'];