Example #1
0
 function AjaxHandler($params)
 {
     switch ($params['action']) {
         case 'attach_swekey':
             if (!empty($params['lms_user_id'])) {
                 $this->AUTH->id = intval($params['lms_user_id']);
                 $this->is_user_logged = true;
             }
             break;
         default:
             break;
     }
     return parent::AjaxHandler($params);
 }
Example #2
0
    public function VerifyUser()
    {
        $this->islogged = false;
        if ($user = $this->DB->GetRow('SELECT id, name, passwd, hosts, lastlogindate, lastloginip, 
			passwdexpiration, passwdlastchange, access, accessfrom, accessto, swekey_id
			FROM users WHERE login=? AND deleted=0', array($this->login))) {
            $this->logname = $user['name'];
            $this->id = $user['id'];
            $this->last = $user['lastlogindate'];
            $this->lastip = $user['lastloginip'];
            $this->passwdexpiration = $user['passwdexpiration'];
            $this->passwdlastchange = $user['passwdlastchange'];
            $this->swekeyid = $user['swekey_id'];
            $this->passverified = $this->VerifyPassword($user['passwd']);
            $this->hostverified = $this->VerifyHost($user['hosts']);
            $this->access = $this->VerifyAccess($user['access']);
            $this->accessfrom = $this->VerifyAccessFrom($user['accessfrom']);
            $this->accessto = $this->VerifyAccessTo($user['accessto']);
            $this->islogged = $this->passverified && $this->hostverified && $this->access && $this->accessfrom && $this->accessto;
            if (ConfigHelper::checkValue(ConfigHelper::getConfig('phpui.use_swekey', false))) {
                require_once LIB_DIR . DIRECTORY_SEPARATOR . 'swekey' . DIRECTORY_SEPARATOR . 'swekey_integration.php';
                $SWEKEY = new SwekeyIntegration();
                $this->swekeyauthenticated = $SWEKEY->IsSwekeyAuthenticated($this->swekeyid);
                if (!$this->swekeyauthenticated && $this->swekeyid) {
                    $this->error = trans('You must login with your Swekey');
                    $this->islogged = false;
                    $SWEKEY->DestroySession();
                }
            }
            if ($this->islogged && $this->passwdexpiration && (time() - $this->passwdlastchange) / 86400 >= $user['passwdexpiration']) {
                $this->SESSION->save('session_passwdrequiredchange', TRUE);
            }
        } else {
            $this->error = trans('Wrong password or login.');
        }
        return $this->islogged;
    }