Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit a1fe64c

Browse files
author
Michael Grauer
committed
ENH: refs #952. Further support upgrade process for 3.2.12.
This fixes a case that would fail if the admin user is logged out, then pulls the latest commit, then tries to login with the remerber me checked.
1 parent a1069b8 commit a1fe64c

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

core/AppController.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,23 @@ public function preDispatch()
108108
if(count($tmp) == 2)
109109
{
110110
$userDao = $userModel->load($tmp[0]);
111-
112-
if(version_compare(Zend_Registry::get('configDatabase')->version, '3.2.12', '>=') &&
113-
$userDao != false && $userModel->hashExists($tmp[1]))
111+
if($userDao != false)
114112
{
115-
$user->Dao = $userDao;
113+
// authenticate valid users in the appropriate method for the
114+
// current application version
115+
if(version_compare(Zend_Registry::get('configDatabase')->version, '3.2.12', '>='))
116+
{
117+
$auth = $userModel->hashExists($tmp[1]);
118+
}
119+
else
120+
{
121+
$auth = $this->User->legacyAuthenticate($userDao, '', '', $tmp[1]);
122+
}
123+
// if authenticated, set the session user to be this user
124+
if($auth)
125+
{
126+
$user->Dao = $userDao;
127+
}
116128
}
117129
}
118130
}

core/controllers/UserController.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ function loginAction()
476476
}
477477
else
478478
{
479+
$passwordHash = md5($instanceSalt.$form->getValue('password'));
479480
$coreAuth = $this->User->legacyAuthenticate($userDao, $instanceSalt, $form->getValue('password'));
480481
}
481482

@@ -490,10 +491,6 @@ function loginAction()
490491
return;
491492
}
492493
}
493-
if(version_compare($currentVersion, '3.2.12', '>=') && $userDao->getSalt() == '')
494-
{
495-
$passwordHash = $this->User->convertLegacyPasswordHash($userDao, $form->getValue('password'));
496-
}
497494
$remember = $form->getValue('remerberMe');
498495
if(isset($remember) && $remember == 1)
499496
{

core/models/pdo/UserModel.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,12 @@ function getUsersFromSearch($search, $userDao, $limit = 14, $group = true, $orde
312312
* used during the upgrade process only, not for general authentication.
313313
* @return True or false: whether the authentication succeeded
314314
*/
315-
function legacyAuthenticate($userDao, $instanceSalt, $password)
315+
function legacyAuthenticate($userDao, $instanceSalt, $password, $hash = false)
316316
{
317-
$hash = md5($instanceSalt.$password);
317+
if(!$hash)
318+
{
319+
$hash = md5($instanceSalt.$password);
320+
}
318321
$sql = $this->database->select()->setIntegrityCheck(false)
319322
->where('user_id = ?', $userDao->getKey());
320323

0 commit comments

Comments
 (0)