diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2018-06-22 00:45:22 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-22 00:45:22 +0300 |
commit | 45018a0e839f71dd8fac892125b77b5bccd1713a (patch) | |
tree | 4bd1aeea82d86139ac406ca4972301c1888cab65 | |
parent | 7ab0335eaf0f5cc7bc115acbf12fda75bd40044f (diff) | |
parent | 8ed50d4b63b4e6f8073fe631721405eeedc45190 (diff) |
Merge pull request #9921 from nextcloud/resetpassword-login-prefill
prefill userid for login after password reset
-rw-r--r-- | core/Controller/LostController.php | 7 | ||||
-rw-r--r-- | core/js/lostpassword.js | 10 | ||||
-rw-r--r-- | tests/Core/Controller/LostControllerTest.php | 2 |
3 files changed, 8 insertions, 11 deletions
diff --git a/core/Controller/LostController.php b/core/Controller/LostController.php index f45de3653ea..d0ed432f03f 100644 --- a/core/Controller/LostController.php +++ b/core/Controller/LostController.php @@ -206,10 +206,11 @@ class LostController extends Controller { } /** + * @param array $data * @return array */ - private function success() { - return array('status'=>'success'); + private function success($data = []) { + return array_merge($data, ['status'=>'success']); } /** @@ -282,7 +283,7 @@ class LostController extends Controller { return $this->error($e->getMessage()); } - return $this->success(); + return $this->success(['user' => $userId]); } /** diff --git a/core/js/lostpassword.js b/core/js/lostpassword.js index 5f81a96cd4f..a51b58a657c 100644 --- a/core/js/lostpassword.js +++ b/core/js/lostpassword.js @@ -162,7 +162,7 @@ OC.Lostpassword = { resetDone : function(result){ var resetErrorMsg; if (result && result.status === 'success'){ - OC.Lostpassword.redirect(); + OC.Lostpassword.redirect('/login?user=' + result.user); } else { if (result && result.msg){ resetErrorMsg = result.msg; @@ -175,12 +175,8 @@ OC.Lostpassword = { } }, - redirect : function(msg){ - if(OC.webroot !== '') { - window.location = OC.webroot; - } else { - window.location = '/'; - } + redirect : function(url){ + window.location = OC.generateUrl(url); }, resetError : function(msg){ diff --git a/tests/Core/Controller/LostControllerTest.php b/tests/Core/Controller/LostControllerTest.php index f35d3b37b80..8ccabfbf79a 100644 --- a/tests/Core/Controller/LostControllerTest.php +++ b/tests/Core/Controller/LostControllerTest.php @@ -571,7 +571,7 @@ class LostControllerTest extends \Test\TestCase { )->willReturn('12345:TheOnlyAndOnlyOneTokenToResetThePassword'); $response = $this->lostController->setPassword('TheOnlyAndOnlyOneTokenToResetThePassword', 'ValidTokenUser', 'NewPassword', true); - $expectedResponse = array('status' => 'success'); + $expectedResponse = array('user' => 'ValidTokenUser', 'status' => 'success'); $this->assertSame($expectedResponse, $response); } |