Skip to content
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
6 changes: 3 additions & 3 deletions core/Controller/LostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}
}

Expand Down
16 changes: 8 additions & 8 deletions tests/Core/Controller/LostControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down