function signOn() { if (isset($_SESSION[':cas']['user'])) { if (($staff = StaffSession::lookup($this->cas->getEmail())) && $staff->getId()) { if (!$staff instanceof StaffSession) { // osTicket <= v1.9.7 or so $staff = new StaffSession($staff->getId()); } return $staff; } else { $_SESSION['_staff']['auth']['msg'] = 'Have your administrator create a local account'; } } }
function authOrCreate($username) { global $cfg; switch ($this->type) { case 'staff': if (($user = StaffSession::lookup($username)) && $user->getId()) { if (!$user instanceof StaffSession) { // osTicket <= v1.9.7 or so $user = new StaffSession($user->getId()); } return $user; } else { $staff_groups = preg_split('/;|,/', $config->get('multiauth-staff-group')); $chkgroup; foreach ($staff_groups as $staff_group) { if ($ldap->checkGroup($name, $staff_group)) { $chkgroup = true; break; } } $config = $this->getConfig(); if ($config->get('multiauth-staff-register') && $chkgroup) { if (!($info = $this->lookup($username, false))) { return; } $errors = array(); $staff = array(); $staff['username'] = $info['username']; $staff['firstname'] = $info['first']; $staff['lastname'] = $info['last']; $staff['email'] = $info['email']; $staff['isadmin'] = 0; $staff['isactive'] = 1; $staff['group_id'] = 1; $staff['dept_id'] = 1; $staff['welcome_email'] = "on"; $staff['timezone_id'] = 8; $staff['isvisible'] = 1; Staff::create($staff, $errors); if (($user = StaffSession::lookup($username)) && $user->getId()) { if (!$user instanceof StaffSession) { $user = new StaffSession($user->getId()); } return $user; } } } break; case 'client': // Lookup all the information on the user. Try to get the email // addresss as well as the username when looking up the user // locally. if (!($info = $this->search($username)[0])) { return; } $acct = ClientAccount::lookupByUsername($username); if ($acct && $acct->getId()) { $client = new ClientSession(new EndUser($acct->getUser())); } if (!$client) { $info['name'] = $info['first'] . " " . $info['last']; $client = new ClientCreateRequest($this, $username, $info); //if (!$cfg || !$cfg->isClientRegistrationEnabled() && self::$config->get('multiauth-force-register')) { // return $client->attemptAutoRegister(); //} } return $client; } return null; }