From fa676f60fbef264b60d0e6d020c22496860e4967 Mon Sep 17 00:00:00 2001 From: James Cole Date: Tue, 2 Jan 2018 17:25:59 +0100 Subject: [PATCH] Internationalise several forms for #1090 --- .../Auth/ForgotPasswordController.php | 20 ++++++++++++++ .../Auth/ResetPasswordController.php | 27 +++++++++++++++++++ resources/lang/en_US/firefly.php | 11 ++++++++ resources/lang/en_US/form.php | 1 + resources/views/auth/login.twig | 16 +++++------ resources/views/auth/passwords/email.twig | 15 +++++------ resources/views/auth/passwords/reset.twig | 18 ++++++------- resources/views/auth/register.twig | 24 +++++++---------- 8 files changed, 93 insertions(+), 39 deletions(-) diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php index bda724008f..3898160a2e 100644 --- a/app/Http/Controllers/Auth/ForgotPasswordController.php +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -22,7 +22,9 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers\Auth; +use FireflyConfig; use FireflyIII\Http\Controllers\Controller; +use FireflyIII\User; use Illuminate\Foundation\Auth\SendsPasswordResetEmails; /** @@ -43,6 +45,24 @@ class ForgotPasswordController extends Controller use SendsPasswordResetEmails; + /** + * Display the form to request a password reset link. + * + * @return \Illuminate\Http\Response + */ + public function showLinkRequestForm() + { + // is allowed to? + $singleUserMode = FireflyConfig::get('single_user_mode', config('firefly.configuration.single_user_mode'))->data; + $userCount = User::count(); + $allowRegistration = true; + if (true === $singleUserMode && $userCount > 0) { + $allowRegistration = false; + } + + return view('auth.passwords.email')->with(compact('allowRegistration')); + } + /** * Create a new controller instance. */ diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php index d07102819d..1231fc749d 100644 --- a/app/Http/Controllers/Auth/ResetPasswordController.php +++ b/app/Http/Controllers/Auth/ResetPasswordController.php @@ -22,8 +22,11 @@ declare(strict_types=1); namespace FireflyIII\Http\Controllers\Auth; +use FireflyConfig; use FireflyIII\Http\Controllers\Controller; +use FireflyIII\User; use Illuminate\Foundation\Auth\ResetsPasswords; +use Illuminate\Http\Request; /** * @codeCoverageIgnore @@ -52,4 +55,28 @@ class ResetPasswordController extends Controller parent::__construct(); $this->middleware('guest'); } + + /** + * Display the password reset view for the given token. + * + * If no token is present, display the link request form. + * + * @param Request $request + * @param string|null $token + * + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + */ + public function showResetForm(Request $request, $token = null) + { + // is allowed to? + $singleUserMode = FireflyConfig::get('single_user_mode', config('firefly.configuration.single_user_mode'))->data; + $userCount = User::count(); + $allowRegistration = true; + if (true === $singleUserMode && $userCount > 0) { + $allowRegistration = false; + } + return view('auth.passwords.reset')->with( + ['token' => $token, 'email' => $request->email, 'allowRegistration' => $allowRegistration] + ); + } } diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.php index 2325b3e52a..a589769235 100644 --- a/resources/lang/en_US/firefly.php +++ b/resources/lang/en_US/firefly.php @@ -141,6 +141,16 @@ return [ 'invalid_server_configuration' => 'Invalid server configuration', 'invalid_locale_settings' => 'Firefly III is unable to format monetary amounts because your server is missing the required packages. There are instructions how to do this.', 'quickswitch' => 'Quickswitch', + 'sign_in_to_start' => 'Sign in to start your session', + 'sign_in' => 'Sign in', + 'register_new_account' => 'Register a new account', + 'forgot_my_password' => 'I forgot my password', + 'problems_with_input' => 'There were some problems with your input.', + 'reset_password' => 'Reset your password', + 'button_reset_password' => 'Reset password', + 'reset_button' => 'Reset', + 'want_to_login' => 'I want to login', + 'button_register' => 'Register', // check for updates: 'update_check_title' => 'Check for updates', @@ -613,6 +623,7 @@ return [ 'bill_will_automatch' => 'Bill will automatically linked to matching transactions', 'skips_over' => 'skips over', + // accounts: 'details_for_asset' => 'Details for asset account ":name"', 'details_for_expense' => 'Details for expense account ":name"', diff --git a/resources/lang/en_US/form.php b/resources/lang/en_US/form.php index ee20875605..0032a58c3a 100644 --- a/resources/lang/en_US/form.php +++ b/resources/lang/en_US/form.php @@ -78,6 +78,7 @@ return [ 'new_email_address' => 'New email address', 'verification' => 'Verification', 'api_key' => 'API key', + 'remember_me' => 'Remember me', 'source_account_asset' => 'Source account (asset account)', 'destination_account_expense' => 'Destination account (expense account)', diff --git a/resources/views/auth/login.twig b/resources/views/auth/login.twig index 2db9351349..37493ba6ca 100644 --- a/resources/views/auth/login.twig +++ b/resources/views/auth/login.twig @@ -29,7 +29,7 @@ @@ -48,36 +48,36 @@ {% endif %}
- +
- +
- +
- +
{% if allowRegistration %} - Register a new account
+ {{ 'register_new_account'|_ }}
{% endif %} - I forgot my password + {{ 'forgot_my_password'|_ }}
{% endblock %} diff --git a/resources/views/auth/passwords/email.twig b/resources/views/auth/passwords/email.twig index 475f9bb7e6..4695a05f4a 100644 --- a/resources/views/auth/passwords/email.twig +++ b/resources/views/auth/passwords/email.twig @@ -11,7 +11,7 @@ {% if errors|length > 0 %}
- Whoops! There were some problems with your input.

+ {{ 'flash_error'|_ }} {{ 'problems_with_input'|_ }}

diff --git a/resources/views/auth/passwords/reset.twig b/resources/views/auth/passwords/reset.twig index bbe9a732d8..b56e40189d 100644 --- a/resources/views/auth/passwords/reset.twig +++ b/resources/views/auth/passwords/reset.twig @@ -4,7 +4,7 @@ {% if errors|length > 0 %}
- Whoops! There were some problems with your input.

+ {{ 'flash_error'|_ }} {{ 'problems_with_input'|_ }}