本文整理汇总了PHP中App\Model\User::findFirst方法的典型用法代码示例。如果您正苦于以下问题:PHP User::findFirst方法的具体用法?PHP User::findFirst怎么用?PHP User::findFirst使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App\Model\User
的用法示例。
在下文中一共展示了User::findFirst方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDetailsForIdentity
protected function getDetailsForIdentity($identity)
{
if (array_key_exists($identity, $this->detailsCache)) {
return $this->detailsCache[$identity];
}
$details = User::findFirst((int) $identity);
$this->detailsCache[$identity] = $details;
return $details;
}
示例2: authenticate
public function authenticate()
{
$username = $this->request->getUsername();
$password = $this->request->getPassword();
$session = $this->authManager->loginWithUsernamePassword(\App\Auth\UsernameAccountType::NAME, $username, $password);
$transformer = new \App\Transformers\UserTransformer();
$transformer->setModelClass('App\\Model\\User');
$user = $this->createItemResponse(\App\Model\User::findFirst($session->getIdentity()), $transformer);
$response = ['token' => $session->getToken(), 'expires' => $session->getExpirationTime(), 'user' => $user];
return $this->createArrayResponse($response, 'data');
}
示例3: login
public function login($data)
{
/** @var \Phalcon\Security $security */
$security = Di::getDefault()->get(Services::SECURITY);
$email = $data[Manager::LOGIN_DATA_EMAIL];
$password = $data[Manager::LOGIN_DATA_PASSWORD];
/** @var \App\Model\User $user */
$user = \App\Model\User::findFirst(['conditions' => 'email = :email:', 'bind' => ['email' => $email]]);
if (!$user) {
return null;
}
if (!$security->checkHash($password, $user->password)) {
return null;
}
return (string) $user->id;
}