Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/37116 #1078

Merged
merged 11 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/Controller/Traits/PasswordManagementTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,20 +166,20 @@ public function requestResetPassword()
'type' => 'password',
]);
if ($resetUser) {
$msg = __d('cake_d_c/users', 'Please check your email to continue with password reset process');
$msg = __d('cake_d_c/users', 'If the account is valid, the system will send an instructional email to the address on record.');
$this->Flash->success($msg);
} else {
$msg = __d('cake_d_c/users', 'The password token could not be generated. Please try again');
$msg = __d('cake_d_c/users', 'There was an error please contact Administrator');
$this->Flash->error($msg);
}

return $this->redirect(['action' => 'login']);
} catch (UserNotFoundException $exception) {
$this->Flash->error(__d('cake_d_c/users', 'User {0} was not found', $reference));
} catch (UserNotActiveException $exception) {
$this->Flash->error(__d('cake_d_c/users', 'The user is not active'));
} catch (UserNotFoundException | UserNotActiveException $exception) {
$msg = __d('cake_d_c/users', 'If the account is valid, the system will send an instructional email to the address on record.');
$this->Flash->success($msg);
} catch (Exception $exception) {
$this->Flash->error(__d('cake_d_c/users', 'Token could not be reset'));
$msg = __d('cake_d_c/users', 'There was an error please contact Administrator');
$this->Flash->error($msg);
$this->log($exception->getMessage());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function testRequestResetPasswordPostValidEmail()
];
$this->post('/users/request-reset-password', $data);
$this->assertRedirect('/login');
$this->assertFlashMessage('Please check your email to continue with password reset process');
$this->assertFlashMessage('If the account is valid, the system will send an instructional email to the address on record.');
$userAfter = $Table->find()->where(['email' => '[email protected]'])->firstOrFail();
$this->assertNotEquals('token-4', $userAfter->token);
$this->assertNotEmpty($userAfter->token);
Expand Down Expand Up @@ -107,6 +107,6 @@ public function testRequestResetPasswordPostInvalidEmail()
];
$this->post('/users/request-reset-password', $data);
$this->assertResponseOk();
$this->assertFlashMessage('User [email protected] was not found');
$this->assertFlashMessage('If the account is valid, the system will send an instructional email to the address on record.');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ public function testRequestPasswordEmptyReference()
->will($this->returnValue($reference));
$this->Trait->Flash->expects($this->any())
->method('error')
->with('Token could not be reset');
->with('There was an error please contact Administrator');

$this->Trait->expects($this->never())
->method('redirect');
Expand All @@ -428,7 +428,7 @@ public function testRequestPasswordEmptyReference()
*/
public function testEnsureUserActiveForResetPasswordFeature($ensureActive)
{
$expectError = $this->never();
$expectError = $this->any();

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