當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Users::findFirst方法代碼示例

本文整理匯總了PHP中Users::findFirst方法的典型用法代碼示例。如果您正苦於以下問題:PHP Users::findFirst方法的具體用法?PHP Users::findFirst怎麽用?PHP Users::findFirst使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Users的用法示例。


在下文中一共展示了Users::findFirst方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: startAction

 /**
  * This action authenticate and logs a user into the application
  */
 public function startAction()
 {
     if ($this->request->isPost()) {
         // Get the data from the user
         $email = $this->request->getPost('email');
         $password = $this->request->getPost('password');
         $tokenKey = $this->request->getPost("token_key");
         $token = $this->request->getPost("token");
         if ($this->security->checkToken($tokenKey, $token)) {
             // Find the user in the database
             $first_user = Users::findFirst(array("(email = :email: OR username = :email:) AND status = '1'", 'bind' => array('email' => $email)));
             // validation password
             if ($first_user) {
                 $user = $this->security->checkHash($password, $first_user->password);
             }
             if ($user != false) {
                 $this->_registerSession($first_user);
                 $this->flash->success('Welcome ' . $first_user->name);
                 // Forward to the 'invoices' controller if the user is valid
                 return $this->dispatcher->forward(array('controller' => 'index', 'action' => 'index'));
             }
         }
         $this->flash->error('Wrong email/password');
     }
     // Forward to the login form again
     return $this->dispatcher->forward(array('controller' => 'login', 'action' => 'index'));
 }
開發者ID:ametsuramet,項目名稱:eazy-dashboard,代碼行數:30,代碼來源:SessionController.php

示例2: profileAction

 /**
  * Edit the active user profile
  *
  */
 public function profileAction()
 {
     //Get session info
     $auth = Session::get('auth');
     //Query the active user
     $user = Users::findFirst($auth['id']);
     if ($user == false) {
         $this->_forward('index/index');
     }
     if (!$this->request->isPost()) {
         Tag::setDefault('name', $user->name);
         Tag::setDefault('email', $user->email);
     } else {
         $name = $this->request->getPost('name', 'string');
         $email = $this->request->getPost('email', 'email');
         $name = strip_tags($name);
         $user->name = $name;
         $user->email = $email;
         if ($user->save() == false) {
             foreach ($user->getMessages() as $message) {
                 Flash::error((string) $message, 'alert alert-error');
             }
         } else {
             Flash::success('Your profile information was updated successfully', 'alert alert-success');
         }
     }
 }
開發者ID:racklin,項目名稱:invo,代碼行數:31,代碼來源:InvoicesController.php

示例3: user

 public function user()
 {
     if (null == $this->user) {
         $this->user = Users::findFirst($this->user_id);
     }
     return $this->user;
 }
開發者ID:huoybb,項目名稱:movie,代碼行數:7,代碼來源:Comments.php

示例4: profileAction

 public function profileAction()
 {
     $auth = $this->session->get('auth');
     $user = Users::findFirst($auth['id']);
     if ($user == false) {
         $this->_forward('index/index');
     }
     $request = $this->request;
     if (!$request->isPost()) {
         Tag::setDefault('name', $user->name);
         Tag::setDefault('email', $user->email);
     } else {
         $name = $request->getPost('name', 'string');
         $email = $request->getPost('email', 'email');
         $name = strip_tags($name);
         $user->name = $name;
         $user->email = $email;
         if ($user->save() == false) {
             foreach ($user->getMessages() as $message) {
                 $this->flash->error((string) $message);
             }
         } else {
             $this->flash->success('更新成功');
         }
     }
 }
開發者ID:lookingatsky,項目名稱:zhonghewanbang,代碼行數:26,代碼來源:InvoicesController.php

示例5: loginAction

 /**
  * Handles login with either POST variables or remember me cookie values. 
  * If success redirects to dashboard (IndexController), unsuccesfull forward to index/loginform
  */
 public function loginAction()
 {
     $rememberMe = false;
     if ($this->request->isPost()) {
         $username = trim($this->request->getPost('username'));
         $password = trim($this->request->getPost('password'));
         $rememberMe = $this->request->getPost('rememberme');
     } else {
         if ($this->cookies->has('username') && $this->cookies->has('password')) {
             $username = trim($this->cookies->get('username')->getValue());
             $password = trim($this->cookies->get('password')->getValue());
         }
     }
     $user = Users::findFirst(array("username = :username:", 'bind' => array('username' => $username)));
     if ($user && $this->security->checkHash($password, $user->password)) {
         $this->_registerSession($user);
         $response = new Response();
         if ($rememberMe) {
             $response->setCookies($this->cookies->set('username', $username, strtotime('+1 year')));
             $response->setCookies($this->cookies->set('password', $password, strtotime('+1 year')));
         }
         $user->last_login = date('Y-m-d H:i:s');
         $user->save();
         return $response->redirect('');
     } else {
         $this->loginFailed = true;
     }
     return $this->dispatcher->forward(array('controller' => 'session', 'action' => 'index'));
 }
開發者ID:joszz,項目名稱:Chell-PHP-Portal,代碼行數:33,代碼來源:SessionController.php

示例6: profileAction

 /**
  * Edit the active user profile
  *
  */
 public function profileAction()
 {
     //Get session info
     $auth = $this->session->get('auth');
     //Query the active user
     $user = Users::findFirst($auth['id']);
     if ($user == false) {
         return $this->_forward('index/index');
     }
     if (!$this->request->isPost()) {
         $this->tag->setDefault('name', $user->name);
         $this->tag->setDefault('email', $user->email);
     } else {
         $name = $this->request->getPost('name', array('string', 'striptags'));
         $email = $this->request->getPost('email', 'email');
         $user->name = $name;
         $user->email = $email;
         if ($user->save() == false) {
             foreach ($user->getMessages() as $message) {
                 $this->flash->error((string) $message);
             }
         } else {
             $this->flash->success('Your profile information was updated successfully');
         }
     }
 }
開發者ID:Rho1and0,項目名稱:invo,代碼行數:30,代碼來源:InvoicesController.php

示例7: submitAction

 public function submitAction()
 {
     // Disable view
     $this->view->disable();
     // Check and get POSTED data
     if ($this->request->isPost() && !empty($login_name = $this->request->getPost("username")) && !empty($password = $this->request->getPost("password"))) {
         $user = Users::findFirst(array("login_name = :login_name: AND active = true", "bind" => array("login_name" => $login_name)));
         if (empty($user)) {
             echo json_encode(array("success" => false, "errorType" => "username", "errorMessage" => "Username tidak dikenal"));
             return;
         } else {
             if ($user->isBanned()) {
                 echo json_encode(array("success" => false, "errorType" => "username", "errorMessage" => "Username ini tidak dapat digunakan kembali"));
                 return;
             } else {
                 if ($user->isSuspended()) {
                     echo json_encode(array("success" => false, "errorType" => "username", "errorMessage" => "Untuk sementara, username ini tidak dapat digunakan"));
                     return;
                 }
             }
         }
         if (!$this->security->checkHash($password, $user->getPassword())) {
             echo json_encode(array("success" => false, "errorType" => "password", "errorMessage" => "Password yang anda masukkan salah"));
             return;
         }
         $this->session->set("auth", array("user" => $user, "role" => Roles::findFirstByIdRole($user->getIdRole())));
         echo json_encode(array("success" => true));
     }
 }
開發者ID:efronnyp,項目名稱:seleksi-supplier,代碼行數:29,代碼來源:AuthController.php

示例8: startAction

 /**
  * This action authenticate and logs a user into the application
  */
 public function startAction()
 {
     //die("session start action");
     if ($this->request->isPost()) {
         // Get the data from the user
         $nom = $this->request->getPost('name');
         $password = $this->request->getPost('password');
         //var_dump($nom . $password);die();
         // Find the user in the database
         $conditions = 'nom = :nom: AND mdp = :password:';
         $user = Users::findFirst(array($conditions, 'bind' => array('nom' => $nom, 'password' => $password)));
         //var_dump($nom ."=>". $password);die("line 48");
         //var_dump($user);die("line 49");
         if ($user != false) {
             //die("coucou " . $nom);
             $this->_registerSession($user);
             $this->flash->success('Welcome ' . $user->nom);
             // Forward to the 'invoices' controller if the user is valid
             return $this->dispatcher->forward(array('controller' => 'index', 'action' => 'listMembers'));
         }
         $this->flash->error('Wrong username/password');
     }
     // Forward to the login form again
     return $this->dispatcher->forward(array('controller' => 'session', 'action' => 'index'));
 }
開發者ID:leyriel,項目名稱:allocuisto_dev,代碼行數:28,代碼來源:SessionController.php

示例9: indexAction

 function indexAction()
 {
     $uid = $this->session->get('user');
     $user = Users::findFirst("id = '{$uid}'");
     $userLeagues = $user->userLeagues;
     $this->view->userLeagues = $userLeagues;
     echo $this->view->render('leagues', 'index');
 }
開發者ID:JApfel,項目名稱:MarketDraft,代碼行數:8,代碼來源:LeaguesController.php

示例10: getTarget

 /**
  * 獲取標簽目標信息
  * @return unknown
  */
 public function getTarget()
 {
     if ($this->type == 1) {
         $target = Articles::findFirst($this->target_id);
     } elseif ($this->type == 2) {
         $target = Users::findFirst($this->target_id);
     }
     return $target;
 }
開發者ID:hongker,項目名稱:Blog,代碼行數:13,代碼來源:Tags.php

示例11: access

 public static function access()
 {
     $key = isset($_POST['key']) ? $_POST['key'] : die('Не передан обязательный параметр key');
     $user = Users::findFirst(array("key = :key:", 'bind' => array('key' => $key)));
     if ($user != false) {
         return true;
     } else {
         die('Неверный api_key');
     }
 }
開發者ID:groumand,項目名稱:restAPI-php-phalcon,代碼行數:10,代碼來源:ApiController.php

示例12: auth

/**
 * Auth the actor role
 *
 * @param \Phalcon\Mvc\Micro $app
 * @return void
 */
function auth($app)
{
    $token = $app->request->get('token', 'string');
    /* @var Users $admin */
    $admin = Users::findFirst("id = " . ADMIN_USER_ID);
    if (!$admin || !$admin instanceof Users || $admin->token !== $token) {
        echo -999;
        die;
    }
}
開發者ID:TagoDR,項目名稱:BladeSoulTool,代碼行數:16,代碼來源:app.php

示例13: getUserAction

 public function getUserAction()
 {
     $userId = $this->request->get('userId', 'int');
     $users = new Users();
     $user = $users->findFirst('id = ' . $userId)->toArray();
     if ($user) {
         $user['registered'] = date('d.m.Y H:i:s', $user['registered']);
     }
     $this->response->setContentType('application/json', 'utf-8');
     $this->response->setJsonContent($user);
     return $this->response;
 }
開發者ID:MikhaylovDmitriy,項目名稱:telejet-soft,代碼行數:12,代碼來源:IndexController.php

示例14: loginAction

 public function loginAction()
 {
     $login = $this->request->getPost('login');
     $password = $this->request->getPost('password');
     $user = Users::findFirst(array("login = ?0", "bind" => array($login)));
     if ($user) {
         if ($this->security->checkHash($password, $user->password)) {
             //The password is valid
         }
     }
     //The validation failed
 }
開發者ID:aodkrisda,項目名稱:phalcon-code,代碼行數:12,代碼來源:security-49.php

示例15: startAction

 public function startAction()
 {
     if ($this->request->isPost()) {
         $email = $this->request->getPost('email');
         $password = $this->request->getPost('password');
         $user = Users::findFirst(array("(email=:email: or username=:email:) and password=:password:", 'bind' => array('email' => $email, 'password' => sha1($password))));
         if ($user != false) {
             $this->_registerSession($user);
             $this->flash->success('Welcome' . $user->name);
             return $this->forward('invoices/index');
         }
     }
 }
開發者ID:playgamelxh,項目名稱:lxh,代碼行數:13,代碼來源:SessionController.php


注:本文中的Users::findFirst方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。