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

[stable10] Make lost password errors distinguishable #28756

Merged
merged 2 commits into from Aug 21, 2017
Jump to file or symbol
Failed to load files and symbols.
+11 −11
Diff settings

Always

Just for now

@@ -159,18 +159,18 @@ private function checkPasswordResetToken($token, $userId) {
$splittedToken = explode(':', $this->config->getUserValue($userId, 'owncloud', 'lostpassword', null));
if(count($splittedToken) !== 2) {
$this->config->deleteUserValue($userId, 'owncloud', 'lostpassword');
throw new \Exception($this->l10n->t('Couldn\'t reset password because the token is invalid'));
throw new \Exception($this->l10n->t('Could not reset password because the token is invalid'));
}
if ($splittedToken[0] < ($this->timeFactory->getTime() - 60*60*12) ||
$user->getLastLogin() > $splittedToken[0]) {
$this->config->deleteUserValue($userId, 'owncloud', 'lostpassword');
throw new \Exception($this->l10n->t('Couldn\'t reset password because the token is expired'));
throw new \Exception($this->l10n->t('Could not reset password because the token expired'));
}
if (!hash_equals($splittedToken[1], $token)) {
$this->config->deleteUserValue($userId, 'owncloud', 'lostpassword');
throw new \Exception($this->l10n->t('Couldn\'t reset password because the token is invalid'));
throw new \Exception($this->l10n->t('Could not reset password because the token does not match'));
}
}
@@ -128,7 +128,7 @@ public function testResetFormInvalidToken() {
'error',
[
'errors' => [
['error' => 'Couldn\'t reset password because the token is invalid'],
['error' => 'Could not reset password because the token is invalid'],
]
],
'guest');
@@ -159,7 +159,7 @@ public function testResetFormInvalidTokenMatch() {
'error',
[
'errors' => [
['error' => 'Couldn\'t reset password because the token is invalid'],
['error' => 'Could not reset password because the token does not match'],
]
],
'guest');
@@ -193,7 +193,7 @@ public function testResetFormExpiredToken() {
'error',
[
'errors' => [
['error' => 'Couldn\'t reset password because the token is expired'],
['error' => 'Could not reset password because the token expired'],
]
],
'guest');
@@ -452,7 +452,7 @@ public function testSetPasswordUnsuccessful() {
$response = $this->lostController->setPassword('wrongToken', $userName, 'NewPassword', true);
$expectedResponse = [
'status' => 'error',
'msg' => 'Couldn\'t reset password because the token is invalid'
'msg' => 'Could not reset password because the token is invalid'
];
$this->assertSame($expectedResponse, $response);
@@ -546,7 +546,7 @@ public function testSetPasswordExpiredToken() {
$response = $this->lostController->setPassword('TheOnlyAndOnlyOneTokenToResetThePassword', 'ValidTokenUser', 'NewPassword', true);
$expectedResponse = [
'status' => 'error',
'msg' => 'Couldn\'t reset password because the token is expired',
'msg' => 'Could not reset password because the token expired',
];
$this->assertSame($expectedResponse, $response);
}
@@ -568,7 +568,7 @@ public function testSetPasswordInvalidDataInDb() {
$response = $this->lostController->setPassword('TheOnlyAndOnlyOneTokenToResetThePassword', 'ValidTokenUser', 'NewPassword', true);
$expectedResponse = [
'status' => 'error',
'msg' => 'Couldn\'t reset password because the token is invalid',
'msg' => 'Could not reset password because the token is invalid',
];
$this->assertSame($expectedResponse, $response);
}
@@ -598,7 +598,7 @@ public function testSetPasswordExpiredTokenDueToLogin() {
$response = $this->lostController->setPassword('TheOnlyAndOnlyOneTokenToResetThePassword', 'ValidTokenUser', 'NewPassword', true);
$expectedResponse = [
'status' => 'error',
'msg' => 'Couldn\'t reset password because the token is expired',
'msg' => 'Could not reset password because the token expired',
];
$this->assertSame($expectedResponse, $response);
}
@@ -613,7 +613,7 @@ public function testIsSetPasswordWithoutTokenFailing() {
$response = $this->lostController->setPassword('', 'ValidTokenUser', 'NewPassword', true);
$expectedResponse = [
'status' => 'error',
'msg' => 'Couldn\'t reset password because the token is invalid'
'msg' => 'Could not reset password because the token is invalid'
];
$this->assertSame($expectedResponse, $response);
}
ProTip! Use n and p to navigate between commits in a pull request.