Fix bug for password change

This commit is contained in:
Frédéric Guillot
2014-08-19 18:29:13 -07:00
parent f8071e7d4a
commit 11b4715d29
3 changed files with 24 additions and 14 deletions

View File

@@ -28,6 +28,7 @@ use Model\LastLogin;
* @property \Model\SubTask $subTask * @property \Model\SubTask $subTask
* @property \Model\Task $task * @property \Model\Task $task
* @property \Model\User $user * @property \Model\User $user
* @property \Model\Webhook $webhook
*/ */
abstract class Base abstract class Base
{ {

View File

@@ -70,6 +70,27 @@ class Authentication extends Base
return false; return false;
} }
/**
* Authenticate a user by different methods
*
* @access public
* @param string $username Username
* @param string $password Password
* @return boolean
*/
public function authenticate($username, $password)
{
// Try first the database auth and then LDAP if activated
if ($this->backend('database')->authenticate($username, $password)) {
return true;
}
else if (LDAP_AUTH && $this->backend('ldap')->authenticate($username, $password)) {
return true;
}
return false;
}
/** /**
* Validate user login form * Validate user login form
* *
@@ -90,17 +111,7 @@ class Authentication extends Base
if ($result) { if ($result) {
$authenticated = false; if ($this->authenticate($values['username'], $values['password'])) {
// Try first the database auth and then LDAP if activated
if ($this->backend('database')->authenticate($values['username'], $values['password'])) {
$authenticated = true;
}
else if (LDAP_AUTH && $this->backend('ldap')->authenticate($values['username'], $values['password'])) {
$authenticated = true;
}
if ($authenticated) {
// Setup the remember me feature // Setup the remember me feature
if (! empty($values['remember_me'])) { if (! empty($values['remember_me'])) {

View File

@@ -307,9 +307,7 @@ class User extends Base
if ($v->execute()) { if ($v->execute()) {
// Check password // Check password
list($authenticated,) = $this->authenticate($_SESSION['user']['username'], $values['current_password']); if ($this->authentication->authenticate($_SESSION['user']['username'], $values['current_password'])) {
if ($authenticated) {
return array(true, array()); return array(true, array());
} }
else { else {