예제 #1
0
 /**
  * Finds user by [[username]]
  *
  * @return User|null
  */
 public function getUser()
 {
     if ($this->_user === false) {
         $this->_user = Users::findByUsername($this->username);
     }
     return $this->_user;
 }
예제 #2
0
파일: LoginForms.php 프로젝트: ewwgit/eptri
 /**
  * Finds user by [[username]]
  *
  * @return User|null
  */
 protected function getUser()
 {
     if ($this->_user === null) {
         $this->_user = Users::findByUsername($this->username);
     }
     return $this->_user;
 }
예제 #3
0
 public function actionAuthenticate()
 {
     $request = Yii::$app->request;
     $username = $request->post('username');
     $user = Users::findByUsername($username);
     // Just create the user if not found
     if (!$user) {
         $user = new Users();
         $user->username = $username;
         $user->save();
     }
     echo json_encode(['auth' => $user->getId() ? true : false, 'id' => $user->id, 'username' => $user->username]);
 }
예제 #4
0
 public function actionGetScore()
 {
     $request = Yii::$app->request;
     $username = $request->post('username');
     $testId = $request->post('testId');
     $user = Users::findByUsername($username);
     $test = Test::findOne($testId);
     if (!$user || !$test) {
         return ['success' => false, 'message' => 'Eiher the user or test was not found'];
     }
     return ['success' => true, 'score' => $test->score];
 }
예제 #5
0
});
Uploads::applyFilter('save', function ($self, $params, $chain) {
    if ($params['data']) {
        $params['entity']->set($params['data']);
        $params['data'] = array();
    }
    if (!$params['entity']->id) {
        $params['entity']->created = date('Y-m-d H:i:s');
    }
    return $chain->next($self, $params, $chain);
});
use lithium\util\Validator;
Validator::add('usernameTaken', function ($value) {
    $success = false;
    if (strlen($value) != 0) {
        $success = count(Users::findByUsername($value)) == 0 ? false : true;
    }
    return !$success;
});
use lithium\core\Libraries;
Libraries::add('upload', array('path' => LITHIUM_APP_PATH . '/libraries/_source/upload/'));
Libraries::add('captcha', array('path' => LITHIUM_APP_PATH . '/libraries/_source/captcha/', 'webroot' => LITHIUM_APP_PATH . '/libraries/_source/captcha/', "bootstrap" => "securimage.php"));
define('_INSTALL', file_exists($_SERVER['DOCUMENT_ROOT'] . "/install") ? '1' : '0');
function getBaseUrl()
{
    $protocol = isset($_SERVER["HTTPS"]) && $_SERVER['HTTPS'] != "off" ? "https" : "http";
    return $protocol . "://" . $_SERVER['HTTP_HOST'];
}
use lithium\core\Environment;
Environment::is(function ($request) {
    return in_array($request->env('SERVER_ADDR'), array('::1', '127.0.0.1')) ? 'development' : 'production';