Merge pull request #2561 from nextcloud/save-timezone-on-login
Save the timezone on login again
This commit is contained in:
commit
e3b2832ee1
|
@ -200,9 +200,11 @@ class LoginController extends Controller {
|
||||||
* @param string $password
|
* @param string $password
|
||||||
* @param string $redirect_url
|
* @param string $redirect_url
|
||||||
* @param boolean $remember_login
|
* @param boolean $remember_login
|
||||||
|
* @param string $timezone
|
||||||
|
* @param string $timezone_offset
|
||||||
* @return RedirectResponse
|
* @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());
|
$currentDelay = $this->throttler->getDelay($this->request->getRemoteAddress());
|
||||||
$this->throttler->sleepDelay($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());
|
$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)) {
|
if ($this->twoFactorManager->isTwoFactorAuthenticated($loginResult)) {
|
||||||
$this->twoFactorManager->prepareTwoFactorLogin($loginResult, $remember_login);
|
$this->twoFactorManager->prepareTwoFactorLogin($loginResult, $remember_login);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* global jstz */
|
/* global jstz */
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$('#timezone-offset').val((-new Date().getTimezoneOffset() / 60));
|
$('#timezone_offset').val((-new Date().getTimezoneOffset() / 60));
|
||||||
$('#timezone').val(jstz.determine().name());
|
$('#timezone').val(jstz.determine().name());
|
||||||
|
|
||||||
// only enable the submit button once we are sure that the timezone is set
|
// only enable the submit button once we are sure that the timezone is set
|
||||||
|
|
|
@ -80,7 +80,7 @@ script('core', [
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</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="timezone" id="timezone"/>
|
||||||
<input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']) ?>">
|
<input type="hidden" name="requesttoken" value="<?php p($_['requesttoken']) ?>">
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
|
@ -337,6 +337,9 @@ class LoginControllerTest extends TestCase {
|
||||||
$user->expects($this->any())
|
$user->expects($this->any())
|
||||||
->method('getUID')
|
->method('getUID')
|
||||||
->will($this->returnValue('uid'));
|
->will($this->returnValue('uid'));
|
||||||
|
$user->expects($this->any())
|
||||||
|
->method('getLastLogin')
|
||||||
|
->willReturn(123456);
|
||||||
$password = 'secret';
|
$password = 'secret';
|
||||||
$indexPageUrl = \OC_Util::getDefaultPageUrl();
|
$indexPageUrl = \OC_Util::getDefaultPageUrl();
|
||||||
|
|
||||||
|
@ -373,11 +376,21 @@ class LoginControllerTest extends TestCase {
|
||||||
$this->config->expects($this->once())
|
$this->config->expects($this->once())
|
||||||
->method('deleteUserValue')
|
->method('deleteUserValue')
|
||||||
->with('uid', 'core', 'lostpassword');
|
->with('uid', 'core', 'lostpassword');
|
||||||
|
$this->config->expects($this->once())
|
||||||
|
->method('setUserValue')
|
||||||
|
->with('uid', 'core', 'timezone', 'Europe/Berlin');
|
||||||
$this->userSession->expects($this->never())
|
$this->userSession->expects($this->never())
|
||||||
->method('createRememberMeToken');
|
->method('createRememberMeToken');
|
||||||
|
|
||||||
|
$this->session->expects($this->exactly(2))
|
||||||
|
->method('set')
|
||||||
|
->withConsecutive(
|
||||||
|
['last-password-confirm', 123456],
|
||||||
|
['timezone', '1']
|
||||||
|
);
|
||||||
|
|
||||||
$expected = new \OCP\AppFramework\Http\RedirectResponse($indexPageUrl);
|
$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() {
|
public function testLoginWithValidCredentialsAndRememberMe() {
|
||||||
|
|
Loading…
Reference in New Issue