Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function identify($user=null,$conditions=null){
- if (empty($user)) {
- $user = $this->user();
- if (empty($user)) {
- return null;
- }
- } elseif (is_object($user) && is_a($user, 'Model')) {
- if (!$user->exists()) {
- return null;
- }
- $user = $user->read();
- $user = $user[$this->userModel];
- } elseif (is_array($user) && isset($user[$this->userModel])) {
- $user = $user[$this->userModel];
- }
- if (isset($user[$this->fields['username']]) && !empty($user[$this->fields['username']]) && !empty($user[$this->fields['password']])) {
- if (trim($user[$this->fields['username']]) == '=' || trim($user[$this->fields['password']]) == '=') {
- return false;
- }
- $username = $user[$this->fields['username']];
- $password = $user[$this->fields['password']];
- } elseif (isset($user[$this->userModel . '.' . $this->fields['username']]) && !empty($user[$this->userModel . '.' . $this->fields['username']])) {
- if (trim($user[$this->userModel . '.' . $this->fields['username']]) == '=' || trim($user[$this->userModel . '.' . $this->fields['password']]) == '=') {
- return false;
- }
- $username = $user[$this->userModel . '.' . $this->fields['username']];
- $password = $user[$this->userModel . '.' . $this->fields['password']];
- } else {
- return false;
- }
- $ldap = new Ldapoperator();
- $authenticates = $ldap->auth($username, $password);
- if($authenticates){
- $userObject=new $this->userModel;
- $user=$userObject->find("first",
- array(
- 'conditions'=> array(
- $this->fields['username']=>$username
- )
- )
- );
- if ($user)
- return parent::identify($user,$conditions);
- }
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement