From 5d1e90d29cf1670af25661f82653268db131a3b7 Mon Sep 17 00:00:00 2001 From: James Cole Date: Tue, 8 Aug 2017 16:30:21 +0200 Subject: [PATCH] Expand verify password routine. --- app/Http/Requests/UserFormRequest.php | 2 +- app/Http/Requests/UserRegistrationRequest.php | 11 ---- app/Validation/FireflyValidator.php | 16 +++-- resources/lang/en_US/form.php | 1 + resources/views/auth/register.twig | 58 ++++++++++++++++++- resources/views/profile/change-password.twig | 2 + 6 files changed, 69 insertions(+), 21 deletions(-) diff --git a/app/Http/Requests/UserFormRequest.php b/app/Http/Requests/UserFormRequest.php index 08a7076038..baba06cc63 100644 --- a/app/Http/Requests/UserFormRequest.php +++ b/app/Http/Requests/UserFormRequest.php @@ -51,7 +51,7 @@ class UserFormRequest extends Request return [ 'id' => 'required|exists:users,id', 'email' => 'email|required', - 'password' => 'confirmed', + 'password' => 'confirmed|secure_password', 'blocked_code' => 'between:0,30', 'blocked' => 'between:0,1|numeric', ]; diff --git a/app/Http/Requests/UserRegistrationRequest.php b/app/Http/Requests/UserRegistrationRequest.php index db2f7bda8c..7875dc5358 100644 --- a/app/Http/Requests/UserRegistrationRequest.php +++ b/app/Http/Requests/UserRegistrationRequest.php @@ -28,17 +28,6 @@ class UserRegistrationRequest extends Request return true; } - /** - * @return array - */ - public function getUserData(): array - { - return [ - 'email' => $this->string('email'), - 'password' => $this->string('password'), - ]; - } - /** * @return array */ diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.php index a5ec19c29e..62f6747123 100644 --- a/app/Validation/FireflyValidator.php +++ b/app/Validation/FireflyValidator.php @@ -284,14 +284,18 @@ class FireflyValidator extends Validator */ public function validateSecurePassword($attribute, $value, $parameters): bool { - $enabled = env('PASSWORD_SERVICE'); - if (!$enabled) { - return true; + $verify = false; + if (isset($this->data['verify_password'])) { + $verify = intval($this->data['verify_password']) === 1; } - /** @var Verifier $service */ - $service = app(Verifier::class); + if ($verify) { + /** @var Verifier $service */ + $service = app(Verifier::class); - return $service->validPassword($value); + return $service->validPassword($value); + } + + return true; } /** diff --git a/resources/lang/en_US/form.php b/resources/lang/en_US/form.php index 10a2aba64b..d06bc2c694 100644 --- a/resources/lang/en_US/form.php +++ b/resources/lang/en_US/form.php @@ -32,6 +32,7 @@ return [ 'journal_source_account_name' => 'Revenue account (source)', 'journal_source_account_id' => 'Asset account (source)', 'BIC' => 'BIC', + 'verify_password' => 'Verify password security', 'account_from_id' => 'From account', 'account_to_id' => 'To account', 'source_account' => 'Source account', diff --git a/resources/views/auth/register.twig b/resources/views/auth/register.twig index 30431d4763..b8621e4395 100644 --- a/resources/views/auth/register.twig +++ b/resources/views/auth/register.twig @@ -22,7 +22,7 @@ work for one (1) month.

{% endif %} -
+
@@ -35,8 +35,16 @@
-
- +
+
+ +
+
+
+
@@ -46,4 +54,48 @@ I forgot my password
+ + + + {% endblock %} diff --git a/resources/views/profile/change-password.twig b/resources/views/profile/change-password.twig index 248c51b604..575c1e3722 100644 --- a/resources/views/profile/change-password.twig +++ b/resources/views/profile/change-password.twig @@ -52,6 +52,8 @@ + {{ ExpandedForm.checkbox('verify_password','1', false) }} +