Skip to content

Commit a4b213c

Browse files
authored
Merge pull request #1079 from CakeDC/feature/37116.cake4
respond with a generic message instead of 'That account does not exist'
2 parents 3ae0426 + 5da6e89 commit a4b213c

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/Controller/Traits/PasswordManagementTrait.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,20 +164,20 @@ public function requestResetPassword()
164164
'type' => 'password',
165165
]);
166166
if ($resetUser) {
167-
$msg = __d('cake_d_c/users', 'Please check your email to continue with password reset process');
167+
$msg = __d('cake_d_c/users', 'If the account is valid, the system will send an instructional email to the address on record.');
168168
$this->Flash->success($msg);
169169
} else {
170-
$msg = __d('cake_d_c/users', 'The password token could not be generated. Please try again');
170+
$msg = __d('cake_d_c/users', 'There was an error please contact Administrator');
171171
$this->Flash->error($msg);
172172
}
173173

174174
return $this->redirect(['action' => 'login']);
175-
} catch (UserNotFoundException $exception) {
176-
$this->Flash->error(__d('cake_d_c/users', 'User {0} was not found', $reference));
177-
} catch (UserNotActiveException $exception) {
178-
$this->Flash->error(__d('cake_d_c/users', 'The user is not active'));
175+
} catch (UserNotFoundException | UserNotActiveException $exception) {
176+
$msg = __d('cake_d_c/users', 'If the account is valid, the system will send an instructional email to the address on record.');
177+
$this->Flash->success($msg);
179178
} catch (Exception $exception) {
180-
$this->Flash->error(__d('cake_d_c/users', 'Token could not be reset'));
179+
$msg = __d('cake_d_c/users', 'There was an error please contact Administrator');
180+
$this->Flash->error($msg);
181181
$this->log($exception->getMessage());
182182
}
183183
}

tests/TestCase/Controller/Traits/Integration/PasswordManagementTraitIntegrationTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function testRequestResetPasswordPostValidEmail()
6161
];
6262
$this->post('/users/request-reset-password', $data);
6363
$this->assertRedirect('/login');
64-
$this->assertFlashMessage('Please check your email to continue with password reset process');
64+
$this->assertFlashMessage('If the account is valid, the system will send an instructional email to the address on record.');
6565
$userAfter = $Table->find()->where(['email' => '4@example.com'])->firstOrFail();
6666
$this->assertNotEquals('token-4', $userAfter->token);
6767
$this->assertNotEmpty($userAfter->token);
@@ -107,6 +107,6 @@ public function testRequestResetPasswordPostInvalidEmail()
107107
];
108108
$this->post('/users/request-reset-password', $data);
109109
$this->assertResponseOk();
110-
$this->assertFlashMessage('User someother.un@example.com was not found');
110+
$this->assertFlashMessage('If the account is valid, the system will send an instructional email to the address on record.');
111111
}
112112
}

tests/TestCase/Controller/Traits/PasswordManagementTraitTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ public function testRequestPasswordEmptyReference()
401401
->will($this->returnValue($reference));
402402
$this->Trait->Flash->expects($this->any())
403403
->method('error')
404-
->with('Token could not be reset');
404+
->with('There was an error please contact Administrator');
405405

406406
$this->Trait->expects($this->never())
407407
->method('redirect');
@@ -415,7 +415,7 @@ public function testRequestPasswordEmptyReference()
415415
*/
416416
public function testEnsureUserActiveForResetPasswordFeature($ensureActive)
417417
{
418-
$expectError = $this->never();
418+
$expectError = $this->any();
419419

420420
if ($ensureActive) {
421421
Configure::write('Users.Registration.ensureActive', true);
@@ -431,8 +431,8 @@ public function testEnsureUserActiveForResetPasswordFeature($ensureActive)
431431
->with('reference')
432432
->will($this->returnValue($reference));
433433
$this->Trait->Flash->expects($expectError)
434-
->method('error')
435-
->with('The user is not active');
434+
->method('success')
435+
->with('If the account is valid, the system will send an instructional email to the address on record.');
436436
$this->Trait->requestResetPassword();
437437
$this->assertNotEquals('xxx', $this->table->get('00000000-0000-0000-0000-000000000001')->token);
438438
}

0 commit comments

Comments
 (0)