Added new public method loginLDAP to AuthLib

This commit is contained in:
Paolo
2019-03-13 10:24:19 +01:00
parent d1b4024b76
commit fd9a2266ec
+33
View File
@@ -154,6 +154,39 @@ class AuthLib
}
}
/**
* Login a user with the given username and password using LDAP
*/
public function loginLDAP($username, $password)
{
$loginUP = $this->_checkLDAPAuthentication($username, $password);
if (isSuccess($loginUP))
{
$this->_ci->PersonModel->resetQuery(); // Reset an eventually already built query
// Retrieves user data from DB using the UID
$personResult = $this->_ci->PersonModel->getByUid($username);
if (hasData($personResult))
{
$person = getData($personResult)[0];
// Stores used data into the authentication object and then into a success object
$loginUP = success(
$this->_createAuthObj($person->person_id, $person->vorname, $person->nachname, $username),
AUTH_SUCCESS
);
$this->_storeAuthObj(getData($loginUP));
}
elseif (isError($personResult)) // blocking error
{
$loginUP = $personResult; // to be displayed
}
}
return $loginUP;
}
//------------------------------------------------------------------------------------------------------------------
// Private methods