Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable10] Save timezone as given during login #31493

Merged
merged 1 commit into from
Jun 4, 2018
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
14 changes: 11 additions & 3 deletions core/Controller/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ public function showLoginForm($user, $redirect_url, $remember_login) {
* user is trying to access files for which he needs to login.
*/

if ((!empty($redirect_url)) and ($remember_login === null) and
($this->userSession->isLoggedIn() === false) and
if (!empty($redirect_url) && ($remember_login === null) &&
($this->userSession->isLoggedIn() === false) &&
(strpos($this->urlGenerator->getAbsoluteURL(urldecode($redirect_url)),
$this->urlGenerator->getAbsoluteURL('/index.php/f/')) !== false)) {

Expand All @@ -193,9 +193,12 @@ public function showLoginForm($user, $redirect_url, $remember_login) {
* @param string $user
* @param string $password
* @param string $redirect_url
* @param string $timezone
* @return RedirectResponse
* @throws \OCP\PreConditionNotMetException
* @throws \OC\User\LoginException
*/
public function tryLogin($user, $password, $redirect_url) {
public function tryLogin($user, $password, $redirect_url, $timezone = null) {
$originalUser = $user;
// TODO: Add all the insane error handling
$loginResult = $this->userSession->login($user, $password);
Expand Down Expand Up @@ -231,6 +234,11 @@ public function tryLogin($user, $password, $redirect_url) {
// User has successfully logged in, now remove the password reset link, when it is available
$this->config->deleteUserValue($userObject->getUID(), 'owncloud', 'lostpassword');

// Save the timezone
if ($timezone !== null) {
$this->config->setUserValue($userObject->getUID(), 'core', 'timezone', $timezone);
}

if ($this->twoFactorManager->isTwoFactorAuthenticated($userObject)) {
$this->twoFactorManager->prepareTwoFactorLogin($userObject);
if (!is_null($redirect_url)) {
Expand Down
2 changes: 1 addition & 1 deletion tests/Core/Controller/LoginControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ public function testLoginWithValidCredentials() {

$expected = new RedirectResponse($indexPageUrl);

$this->loginController = $this->getMockBuilder('OC\Core\Controller\LoginController')
$this->loginController = $this->getMockBuilder(LoginController::class)
->setMethods(['getDefaultUrl'])
->setConstructorArgs([
'core',
Expand Down