当前位置: 首页>>代码示例>>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;未经允许,请勿转载。