debug("Starting user load for ". $name); if(empty($name) || empty($password)) return false; $input_hash = $password; $passwordEncrypted = false; if (!empty($PARAMS) && isset($PARAMS['passwordEncrypted']) && $PARAMS['passwordEncrypted']) { $passwordEncrypted = true; }// if if (!$passwordEncrypted) { $input_hash = SugarAuthenticate::encodePassword($password); } // if $user_id = $this->authenticateUser($name, $input_hash, $fallback); if(empty($user_id)) { $GLOBALS['log']->fatal('SECURITY: User authentication for '.$name.' failed'); return false; } $this->loadUserOnSession($user_id); return true; } /** * Loads the current user bassed on the given user_id * * @param STRING $user_id * @return boolean */ function loadUserOnSession($user_id=''){ if(!empty($user_id)){ $_SESSION['authenticated_user_id'] = $user_id; } if(!empty($_SESSION['authenticated_user_id']) || !empty($user_id)){ $GLOBALS['current_user'] = new User(); if($GLOBALS['current_user']->retrieve($_SESSION['authenticated_user_id'])){ return true; } } return false; } } ?>