Fixed Password Reset handling (#1365)

* Fixed Passwort Reset handling so the message is the same whether the E-Mail address exists or not.

* Fixed spelling & Test

* Fixed Typo

* Improved Staff PW Reset handling and removed both Exceptions to return true

* Improved grammar & wording

---------

Co-authored-by: Christoph Schläpfer <c.schlaepfer@datact.ch>
Co-authored-by: Anuril <ta@TAPC01.localdomain>
Co-authored-by: Belle Aerni <belleaerni@gmail.com>
This commit is contained in:
authored and GitHub committed 2023-07-30 06:58:11 -07:00
1 parent fd872ac941
commit 9e4e3023fa
5 files changed
+7 -7

No files matched your search

+1 -1
View File
@@ -160,7 +160,7 @@ class Guest extends \Api_Abstract
$c = $this->di['db']->findOne('Client', 'email = ?', [$data['email']]);
if (!$c instanceof \Model_Client) {
throw new \Box_Exception('Email not found in our database');
return true;
}
$hash = hash('sha256', time() . random_bytes(13));
@@ -59,7 +59,7 @@ $(function() {
'guest/client/reset_password',
$(this).serialize(),
function(result) {
bb.msg("{{ 'Password reset confirmation email was sent'|trans }}");
bb.msg("{{ 'A password reset confirmation email will be sent to you if we found an account with that email address.'|trans }}");
}
);
+1 -1
View File
@@ -145,7 +145,7 @@ class Guest extends \Api_Abstract
$c = $this->di['db']->findOne('Admin', 'email = ?', [$data['email']]);
if (!$c instanceof \Model_Admin) {
throw new \Box_Exception('Email not found in our database');
return true;
}
$hash = hash('sha256', time() . random_bytes(13));
@@ -15,7 +15,7 @@
<div class="card-body">
<h2 class="h2 text-center mb-4">{{ 'Reset your password' | trans }}</h2>
<p class="text-muted mb-4">{{ 'Enter your email address. You will receive a confirmation link if your account exists.' | trans }}</p>
<form class="api-form" action="{{ 'api/guest/staff/passwordreset'|link }}" method="post" data-api-redirect="{{ 'index'|alink }}">
<form class="api-form" action="{{ 'api/guest/staff/passwordreset'|link }}" method="post" data-api-redirect="{{ 'index'|alink }}" data-api-msg="{{ 'A password reset confirmation email will be sent to you if we found an account with that email address.'|trans }}">
<input type="hidden" name="CSRFToken" value="{{ CSRFToken }}"/>
<div class="mb-3">
<label class="form-label" for="inputEmail">{{ 'Email address' | trans }}</label>
+3 -3
View File
@@ -295,9 +295,9 @@ class GuestTest extends \BBTestCase {
$client = new \Box\Mod\Client\Api\Guest();
$client->setDi($di);
$this->expectException(\Box_Exception::class);
$this->expectExceptionMessage('Email not found in our database');
$client->reset_password($data);
// expects true because we don't want to give away if the email exists or not
$result = $client->reset_password($data);
$this->assertTrue($result);
}
public function testconfirm_reset()