aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/Controller/LoginController.php9
-rw-r--r--core/js/visitortimezone.js2
-rw-r--r--core/templates/login.php2
-rw-r--r--tests/Core/Controller/LoginControllerTest.php15
4 files changed, 24 insertions, 4 deletions
diff --git a/core/Controller/LoginController.php b/core/Controller/LoginController.php
index c3ccac37f78..b6add48ef61 100644
--- a/core/Controller/LoginController.php
+++ b/core/Controller/LoginController.php
@@ -200,9 +200,11 @@ class LoginController extends Controller {
* @param string $password
* @param string $redirect_url
* @param boolean $remember_login
+ * @param string $timezone
+ * @param string $timezone_offset
* @return RedirectResponse
*/
- public function tryLogin($user, $password, $redirect_url, $remember_login = false) {
+ public function tryLogin($user, $password, $redirect_url, $remember_login = false, $timezone = '', $timezone_offset = '') {
$currentDelay = $this->throttler->getDelay($this->request->getRemoteAddress());
$this->throttler->sleepDelay($this->request->getRemoteAddress());
@@ -247,6 +249,11 @@ class LoginController extends Controller {
$this->session->set('last-password-confirm', $loginResult->getLastLogin());
+ if ($timezone_offset !== '') {
+ $this->config->setUserValue($loginResult->getUID(), 'core', 'timezone', $timezone);
+ $this->session->set('timezone', $timezone_offset);
+ }
+
if ($this->twoFactorManager->isTwoFactorAuthenticated($loginResult)) {
$this->twoFactorManager->prepareTwoFactorLogin($loginResult, $remember_login);
diff --git a/core/js/visitortimezone.js b/core/js/visitortimezone.js
index e6e99ee7e20..e984c90a894 100644
--- a/core/js/visitortimezone.js
+++ b/core/js/visitortimezone.js
@@ -1,6 +1,6 @@
/* global jstz */
$(document).ready(function () {
- $('#timezone-offset').val((-new Date().getTimezoneOffset() / 60));
+ $('#timezone_offset').val((-new Date().getTimezoneOffset() / 60));
$('#timezone').val(jstz.determine().name());
// only enable the submit button once we are sure that the timezone is set
diff --git a/core/templates/login.php b/core/templates/login.php
index 46045f86b50..c200dfe366b 100644
--- a/core/templates/login.php
+++ b/core/templates/login.php
@@ -80,7 +80,7 @@ script('core', [
<?php endif; ?>
</div>
- <input type="hidden" name="timezone-offset" id="timezone-offset"/>
+ <input type="hidden" name="timezone_offset" id="timezone_offset"/>
<input type="hidden" name="timezone" id="timezone"/>
<input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']) ?>">
</fieldset>
diff --git a/tests/Core/Controller/LoginControllerTest.php b/tests/Core/Controller/LoginControllerTest.php
index d16b9b114f3..600179a1dc5 100644
--- a/tests/Core/Controller/LoginControllerTest.php
+++ b/tests/Core/Controller/LoginControllerTest.php
@@ -337,6 +337,9 @@ class LoginControllerTest extends TestCase {
$user->expects($this->any())
->method('getUID')
->will($this->returnValue('uid'));
+ $user->expects($this->any())
+ ->method('getLastLogin')
+ ->willReturn(123456);
$password = 'secret';
$indexPageUrl = \OC_Util::getDefaultPageUrl();
@@ -373,11 +376,21 @@ class LoginControllerTest extends TestCase {
$this->config->expects($this->once())
->method('deleteUserValue')
->with('uid', 'core', 'lostpassword');
+ $this->config->expects($this->once())
+ ->method('setUserValue')
+ ->with('uid', 'core', 'timezone', 'Europe/Berlin');
$this->userSession->expects($this->never())
->method('createRememberMeToken');
+ $this->session->expects($this->exactly(2))
+ ->method('set')
+ ->withConsecutive(
+ ['last-password-confirm', 123456],
+ ['timezone', '1']
+ );
+
$expected = new \OCP\AppFramework\Http\RedirectResponse($indexPageUrl);
- $this->assertEquals($expected, $this->loginController->tryLogin($user, $password, null));
+ $this->assertEquals($expected, $this->loginController->tryLogin($user, $password, null, false, 'Europe/Berlin', '1'));
}
public function testLoginWithValidCredentialsAndRememberMe() {