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


PHP UserRepository::findOneBy方法代码示例

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


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

示例1: authenticate

 /**
  * Using the given email finds the user and verifies it's password.
  * If the user is not fund or if the password is wrong, it throws.
  *
  * @param array $credentials
  * @throws AuthenticationException
  * @return User|NULL
  */
 public function authenticate(array $credentials)
 {
     list($username, $password) = $credentials;
     if (!($user = $this->userRepository->findOneBy(['email' => $username]))) {
         throw new AuthenticationException("User '{$username}' not found.", self::IDENTITY_NOT_FOUND);
     } elseif (!$user->verifyPassword($password)) {
         throw new AuthenticationException('Invalid password.', self::INVALID_CREDENTIAL);
     }
     return $user;
 }
开发者ID:martinmayer,项目名称:notejam,代码行数:18,代码来源:Authenticator.php

示例2: startup

 protected function startup()
 {
     parent::startup();
     if ($this->key) {
         if (($user = $this->userRepository->findOneBy(array('userKey' => $this->key))) === NULL) {
             throw new BadRequestException();
         }
         $this->userRepository->delete($user);
         $this->flashMessage('Byl jste odhlášen z newsletteru.', 'success');
         $this->redirect('this', array('key' => NULL));
     }
 }
开发者ID:venne,项目名称:newsletter-module,代码行数:12,代码来源:RoutePresenter.php

示例3: authenticate

 /**
  * @param array $credentials
  * @return UserTable|Nette\Security\IIdentity
  * @throws \Nette\Security\AuthenticationException
  */
 public function authenticate(array $credentials)
 {
     list($username, $password) = $credentials;
     $query = $this->userRepository->createQuery();
     $query->where('@login', $username);
     try {
         $user = $this->userRepository->findOneBy($query);
     } catch (NotFoundException $e) {
         throw new Nette\Security\AuthenticationException('The username is incorrect.', self::IDENTITY_NOT_FOUND);
     }
     if (!$user->isPasswordValid($password)) {
         throw new Nette\Security\AuthenticationException('The password is incorrect.', self::INVALID_CREDENTIAL);
     }
     return $user;
 }
开发者ID:joseki,项目名称:sandbox,代码行数:20,代码来源:Authenticator.php

示例4: getUserByUsername

 /**
  * @return array
  */
 public function getUserByUsername($username)
 {
     return $this->repository->findOneBy(array('username' => $username));
 }
开发者ID:cobase,项目名称:cobase,代码行数:7,代码来源:UserService.php


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