diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2019-08-28 11:21:16 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-28 11:21:16 +0300 |
commit | c9f390de4f3cfb4b903c62b1a38a21aad98d6022 (patch) | |
tree | 37eff5d3a4c1d022ed9d398efb654833a585ea87 /lib/Controller | |
parent | 91017269cd05e3f1827728d6adc8d56a6ede6ad6 (diff) | |
parent | bff5d29326aa858f056b66934c50430cce74e923 (diff) |
Merge pull request #2121 from nextcloud/get-password-from-session-if-not-given-when-joining-room
Get password from session if not given when joining room
Diffstat (limited to 'lib/Controller')
-rw-r--r-- | lib/Controller/PageController.php | 13 | ||||
-rw-r--r-- | lib/Controller/RoomController.php | 5 |
2 files changed, 10 insertions, 8 deletions
diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index 8ec6e6d05..8f65a6932 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -160,8 +160,6 @@ class PageController extends Controller { $token = ''; } - $this->talkSession->removePasswordForRoom($token); - if ($room instanceof Room && $room->hasPassword()) { // If the user joined themselves or is not found, they need the password. try { @@ -172,12 +170,14 @@ class PageController extends Controller { } if ($requirePassword) { + $password = $password !== '' ? $password : (string) $this->talkSession->getPasswordForRoom($token); $passwordVerification = $room->verifyPassword($password); if ($passwordVerification['result']) { - $this->talkSession->setPasswordForRoom($token, $token); + $this->talkSession->setPasswordForRoom($token, $password); } else { + $this->talkSession->removePasswordForRoom($token); if ($passwordVerification['url'] === '') { return new TemplateResponse($this->appName, 'authenticate', [ 'wrongpw' => $password !== '', @@ -226,13 +226,14 @@ class PageController extends Controller { ])); } - $this->talkSession->removePasswordForRoom($token); if ($room->hasPassword()) { - $passwordVerification = $room->verifyPassword($password); + $password = $password !== '' ? $password : (string) $this->talkSession->getPasswordForRoom($token); + $passwordVerification = $room->verifyPassword($password); if ($passwordVerification['result']) { - $this->talkSession->setPasswordForRoom($token, $token); + $this->talkSession->setPasswordForRoom($token, $password); } else { + $this->talkSession->removePasswordForRoom($token); if ($passwordVerification['url'] === '') { return new TemplateResponse($this->appName, 'authenticate', [ 'wrongpw' => $password !== '', diff --git a/lib/Controller/RoomController.php b/lib/Controller/RoomController.php index 8277e2600..bef74ff46 100644 --- a/lib/Controller/RoomController.php +++ b/lib/Controller/RoomController.php @@ -879,10 +879,11 @@ class RoomController extends AEnvironmentAwareController { $user = $this->userManager->get($this->userId); try { + $result = $room->verifyPassword((string) $this->session->getPasswordForRoom($token)); if ($user instanceof IUser) { - $newSessionId = $room->joinRoom($user, $password, $this->session->getPasswordForRoom($token) === $room->getToken()); + $newSessionId = $room->joinRoom($user, $password, $result['result']); } else { - $newSessionId = $room->joinRoomGuest($password, $this->session->getPasswordForRoom($token) === $room->getToken()); + $newSessionId = $room->joinRoomGuest($password, $result['result']); } } catch (InvalidPasswordException $e) { return new DataResponse([], Http::STATUS_FORBIDDEN); |