当前位置: 首页>>代码示例>>PHP>>正文


PHP User::findFirst方法代码示例

本文整理汇总了PHP中User::findFirst方法的典型用法代码示例。如果您正苦于以下问题:PHP User::findFirst方法的具体用法?PHP User::findFirst怎么用?PHP User::findFirst使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在User的用法示例。


在下文中一共展示了User::findFirst方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: gpsAction

 /**
  * GPS安装
  */
 public function gpsAction()
 {
     if ($this->isAjax()) {
         $data = $this->request->getPost();
         $uid = $data['uid'];
         !$uid and $this->error('参数错误');
         $data['gps'] = 1;
         $model = new LoanForm('gps');
         if ($result = $model->validate($data)) {
             if ($model->sign()) {
                 Log::add($uid, $this->getOperatorId(), \App\Config\Log::loanOperate('gps'));
                 $this->success('操作成功');
             } else {
                 $this->error('操作失败');
             }
         } else {
             $this->error('验证失败');
         }
         exit;
     }
     $uid = $this->urlParam();
     empty($uid) and $this->pageError('param');
     $loan = Loan::findByUid($uid);
     $user = User::findFirst($uid)->toArray();
     $this->view->setVars(['loan' => $loan, 'user' => $user]);
     $this->view->pick('afterrc/detail');
 }
开发者ID:Crocodile26,项目名称:php-1,代码行数:30,代码来源:GpsController.php

示例2: find_by_name

 public static function find_by_name($username)
 {
     $conditions = "username = :name:";
     $parameters = array("name" => $username);
     $user = User::findFirst(array($conditions, "bind" => $parameters));
     return $user;
 }
开发者ID:hyfjjjj,项目名称:HHA-Web,代码行数:7,代码来源:Accout.php

示例3: indexAction

 public function indexAction()
 {
     if ($this->request->hasPost('up')) {
         $this->view->setRenderLevel(View::LEVEL_ACTION_VIEW);
     }
     if ($this->session->has('user_id')) {
         $id = $this->session->get('user_id');
         $user = User::findFirst($id);
         foreach ($user->offers as $offers) {
             $image = unserialize($offers->image);
             if (isset($image['image-big-1'])) {
                 $im = 1;
             } else {
                 $im = 0;
             }
             $off[$offers->id]['name'] = array($offers->name, $im, $offers->status, $offers->user->phone, $offers->categories->name);
             if (isset($offers->id)) {
                 foreach ($offers->dannoffers as $dan) {
                     $off[$offers->id][$dan->fieldtype->id] = $dan->dann;
                 }
             }
         }
     }
     //  $this->elements->var_print($off);
     $this->view->setVars(array("cn" => count($user->offers), "off" => $off = isset($off) ? $off : false));
 }
开发者ID:qtebest-dev,项目名称:tractor,代码行数:26,代码来源:MyoffersController.php

示例4: loginAction

 /**
  * Login action, detect if is a valid or invalid user
  */
 public function loginAction()
 {
     $form = new LoginForm();
     if ($this->request->isPost()) {
         if ($form->isValid($this->request->getPost()) != false) {
             $password = $this->request->getPost('password');
             //Find the username and check if this is active into the application
             $user = User::findFirst(array("username = :username: AND active = 1", 'bind' => array('username' => strtolower($this->request->getPost('username', 'striptags')))));
             // successfully find
             if ($user && $this->security->checkHash($password, $user->password)) {
                 //Sent the user to set into the application
                 $this->auth->setAccess($user);
                 //Remember me: If is diferent to false assign a token to the user
                 if ($this->request->getPost('remember') != "false") {
                     $user->assign(array('token' => $this->request->getPost('remember')));
                     if (!$user->save()) {
                         $this->flash->error($user->getMessages());
                     }
                 }
                 return $this->response->redirect('dashboard');
             } else {
                 $form->addFormMessages('username', 'Username name is invalid or not has been activated');
                 $form->addFormMessages('password', 'information does not match');
             }
         }
     }
     $this->view->form = $form;
 }
开发者ID:Pablo251,项目名称:Kangoo,代码行数:31,代码来源:SessionController.php

示例5: LoginAction

 /**
  * @Route("/login", methods = {"POST", "OPTIONS"})
  */
 public function LoginAction()
 {
     //Post传过来的是一个无名的json数据,所以只能getRawBody
     $info = $this->request->getJsonRawBody();
     if (!isset($info->username) || !isset($info->password)) {
         $this->response->setJsonContent(['message' => 'No Data!']);
         $this->response->send();
         return;
     }
     $username = $info->username;
     $password = $info->password;
     $user = User::findFirst(['conditions' => 'name=?1', 'bind' => [1 => $username]]);
     if ($user == null) {
         $this->response->setJsonContent(['message' => '用户不存在']);
     } elseif ($user->password != $password) {
         $this->response->setJsonContent(['message' => '密码错误']);
     } else {
         //            $this->session->set('user_id', $user_array['id']);
         //            $this->session->set('user_name', $user_array['name']);
         //            $this->session->set('user_role', $user_array['role']);
         $this->response->setJsonContent(['user_id' => $user->id, 'user_name' => $user->name, 'user_role' => $user->role]);
     }
     $this->response->send();
     return;
 }
开发者ID:sify21,项目名称:pmail,代码行数:28,代码来源:AuthController.php

示例6: confirmAction

 public function confirmAction()
 {
     $this->view->disable();
     $mail = $this->dispatcher->getParam('mail');
     $user = User::findFirst(array('conditions' => 'mail = ?1', 'bind' => array(1 => $mail)));
     if ($user) {
         $conf = Confirmation::findFirst(array('conditions' => 'user = ?1', 'bind' => array(1 => $user->id)));
         if ($conf) {
             if ($conf->code == $this->dispatcher->getParam('code')) {
                 $user->confirmed = 1;
                 if ($user->save()) {
                     $this->_login($user);
                     $conf->delete();
                     message($this, "s", "Аккаунт подтвержден. Добро пожаловать, " . $user->name);
                     return $this->response->redirect();
                 } else {
                     message($this, "d", "Ошибка активации. Попробуйте позже");
                     return $this->response->redirect();
                 }
             } else {
                 message($this, "d", "Код подтверждения не подходит");
                 return $this->response->redirect();
             }
         } else {
             message($this, "w", "Пользователь уже подтвержден");
             return $this->response->redirect();
         }
     } else {
         message($this, "d", "Пользователя " . $mail . " не существует");
         return $this->response->redirect();
     }
 }
开发者ID:Flerki,项目名称:CarRepairTotal,代码行数:32,代码来源:IndexController.php

示例7: indexAction

 public function indexAction()
 {
     $this->view->products = Product::find();
     if ($this->session->get("auth")) {
         $this->view->user = User::findFirst($this->session->get("auth")['id']);
     }
 }
开发者ID:KarimTaha,项目名称:AdvancedLab,代码行数:7,代码来源:IndexController.php

示例8: mapAction

 public function mapAction($idVisit)
 {
     $visit = Visit::findFirst(array("conditions" => "idVisit = ?1", "bind" => array(1 => $idVisit)));
     if (!$visit) {
         $this->flashSession->error("Ocurrio un error procesando su solicitud, por favor intentelo nuevamente.");
         return $this->response->redirect('index');
     }
     $user = User::findFirst(array("conditions" => "idUser = ?1 AND idAccount = ?2", "bind" => array(1 => $visit->idUser, 2 => $this->user->idAccount)));
     if (!$user) {
         $this->flashSession->error("Ocurrio un error procesando su solicitud, por favor intentelo nuevamente.");
         return $this->response->redirect('visit/index');
     }
     try {
         $sql_rows = "SELECT v.idVisit AS idUser, v.start AS date, u.name AS name, u.lastName AS lastname, vt.name AS visit, c.name AS client, v.battery AS battery, v.latitude AS latitude, v.longitude AS longitude, v.location AS location " . "FROM Visit AS v " . " JOIN User AS u ON (u.idUser = v.idUser) " . " JOIN Visittype AS vt ON (vt.idVisittype = v.idVisittype) " . " JOIN Client AS c ON (c.idClient = v.idClient) " . " WHERE v.idVisit = {$idVisit}";
         //            $this->logger->log($sql_rows);
         $modelsManager = \Phalcon\DI::getDefault()->get('modelsManager');
         $rows = $modelsManager->executeQuery($sql_rows);
         $this->view->setVar('visit', $rows->getFirst());
         $this->view->setVar('user', $user);
     } catch (Exception $e) {
         $this->flashSession->error($e->getMessage());
         $this->trace("fail", $e->getMessage());
         return $this->response->redirect('visit/index');
     }
 }
开发者ID:dorianlopez,项目名称:track,代码行数:25,代码来源:VisitController.php

示例9: tryLogin

 public function tryLogin($data)
 {
     // Reject requests
     if ($this->isExceedingRateLimit(2)) {
         $this->response->setStatusCode(429, 'Too many requests');
         $this->flash->notice('Too many requests.');
         return false;
     }
     /** @var User $user */
     $user = User::findFirst(['email = :email:', 'bind' => ['email' => $data['user']]]);
     // Sleep for 1-500ms
     usleep(mt_rand(1000, 500000));
     if ($user && $user->validatePassword($data['password'])) {
         // Validate TOTP token
         // This needs to be done at this stage as the two factor auth key is
         // encrypted with the user's password.
         if ($otpKey = $user->getOtpKey($data['password'])) {
             $otp = new \Rych\OTP\TOTP($otpKey);
             if (!$otp->validate($data['token'])) {
                 $this->flash->error('Incorrect login details');
                 return false;
             }
         }
         $keyService = new \Stecman\Passnote\AccountKeyService();
         $keyService->unlockAccountKeyForSession($user, $data['password']);
         $this->session->set(Security::SESSION_USER_ID, $user->id);
         $this->session->set(Security::SESSION_KEY, $user->getSessionKey());
         session_regenerate_id();
         $this->response->redirect('');
     } else {
         // Keep timing
         $this->security->hash(openssl_random_pseudo_bytes(12));
         $this->flash->error('Incorrect login details');
     }
 }
开发者ID:stecman,项目名称:passnote,代码行数:35,代码来源:AuthController.php

示例10: getUser

 protected function getUser()
 {
     static $user;
     if (!$user && ($auth = $this->getAuth()) && $auth['user_id']) {
         $user = User::findFirst(array('conditions' => 'id = ?1', 'bind' => array(1 => $auth['user_id'])));
     }
     return $user;
 }
开发者ID:Flerki,项目名称:CarRepairTotal,代码行数:8,代码来源:ControllerBase.php

示例11: getCurrentUser

 /**
  * @return \User
  */
 public static function getCurrentUser()
 {
     $di = \Phalcon\DI::getDefault();
     $session = $di->get('session');
     if ($id = $session->get(self::SESSION_USER_ID)) {
         return User::findFirst($id);
     }
 }
开发者ID:stecman,项目名称:passnote,代码行数:11,代码来源:Security.php

示例12: onConstruct

 public function onConstruct()
 {
     $userid = \User::check_token();
     $user = \User::findFirst([['userid' => $userid]]);
     if ($user) {
         $this->user = $user->attrs();
     }
 }
开发者ID:nisnaker,项目名称:tu,代码行数:8,代码来源:BaseController.php

示例13: detailAction

 public function detailAction()
 {
     $uid = $this->urlParam();
     empty($uid) and $this->pageError('param');
     $loan = Loan::findByUid($uid);
     $user = User::findFirst($uid)->toArray();
     $this->view->setVars(['loan' => $loan, 'user' => $user]);
 }
开发者ID:Crocodile26,项目名称:php-1,代码行数:8,代码来源:FinanceController.php

示例14: createAssocAction

 public function createAssocAction()
 {
     $user = User::findFirst();
     $project = new Project();
     $project->user = $user;
     $project->title = "Moon walker";
     $result = $project->save();
 }
开发者ID:BBK-PiJ-2014-83,项目名称:learning-phalcon,代码行数:8,代码来源:UserController.php

示例15: principalAction

 public function principalAction()
 {
     $username = "pablo251";
     $token = "ly4b35jvokj7cik9541ug6weqgjsjor";
     $user = User::findFirst(array("username = :username: and token = :token: AND active = 1", 'bind' => array('username' => strtolower($username), 'token' => $token)));
     if ($user == null) {
         echo "Como tal";
     }
     print_r($user);
 }
开发者ID:Pablo251,项目名称:Kangoo,代码行数:10,代码来源:IndexController.php


注:本文中的User::findFirst方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。