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


PHP User\UserInterface类代码示例

本文整理汇总了PHP中Symfony\Component\Security\Core\User\UserInterface的典型用法代码示例。如果您正苦于以下问题:PHP UserInterface类的具体用法?PHP UserInterface怎么用?PHP UserInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: isEqualTo

 public function isEqualTo(UserInterface $user)
 {
     if ($this->username == $user->getUsername()) {
         return true;
     }
     return false;
 }
开发者ID:flobbie,项目名称:PasswordSafe,代码行数:7,代码来源:User.php

示例2: logUser

 private function logUser(UserInterface $user, $password)
 {
     $token = new UsernamePasswordToken($user, $password, 'secured_area', $user->getRoles());
     $request = $this->getRequest();
     $session = $request->getSession();
     $session->set('_security_secured_area', serialize($token));
 }
开发者ID:astrakel,项目名称:web,代码行数:7,代码来源:UHUSecurityController.php

示例3: getSecret

 /**
  * {@inheritdoc}
  */
 protected function getSecret(UserInterface $user)
 {
     if ($user instanceof AdvancedApiUserInterface) {
         return $user->getApiKeys();
     }
     return parent::getSecret($user);
 }
开发者ID:xamin123,项目名称:platform,代码行数:10,代码来源:WsseAuthProvider.php

示例4: updateLastLogin

 /**
  * Update the users last login.
  *
  * @param UserInterface $user
  */
 protected function updateLastLogin($user)
 {
     if ($user instanceof BaseUser) {
         $user->setLastLogin(new \DateTime());
         $this->entityManager->flush();
     }
 }
开发者ID:sulu,项目名称:sulu,代码行数:12,代码来源:LastLoginListener.php

示例5: authenticateUser

 private function authenticateUser(UserInterface $user)
 {
     $providerKey = 'secured_area';
     // your firewall name
     $token = new UsernamePasswordToken($user, null, $providerKey, $user->getRoles());
     $this->getSecurityContext()->setToken($token);
 }
开发者ID:bamper,项目名称:symfony2-ep4,代码行数:7,代码来源:RegisterController.php

示例6: isEqualTo

 public function isEqualTo(UserInterface $user)
 {
     if (!$user instanceof CorredorUser || $this->password !== $user->getPassword() || $this->salt !== $user->getSalt() || $this->username !== $user->getUsername()) {
         return false;
     }
     return true;
 }
开发者ID:eduardobenito10,项目名称:CorredoresRioja,代码行数:7,代码来源:CorredorUser.php

示例7: isEqualTo

 /**
  * {@inheritDoc}
  */
 public function isEqualTo(UserInterface $user)
 {
     if ($user instanceof FacebookUser && $user->getId() === $this->getId()) {
         return true;
     }
     return false;
 }
开发者ID:otobank,项目名称:facebook-bundle,代码行数:10,代码来源:FacebookUser.php

示例8: validateDigest

 /**
  * {@InheritDoc}
  *
  * @throws NonceExpiredException
  */
 public function validateDigest(WsseUserToken $wsseToken, UserInterface $user)
 {
     $created = $wsseToken->created;
     $nonce = $wsseToken->nonce;
     $digest = $wsseToken->digest;
     $secret = $user->getPassword();
     // Check created time is not too far in the future (leaves 5 minutes margin)
     if (strtotime($created) > time() + 300) {
         throw new WsseAuthenticationException(sprintf('Token created date cannot be in future (%d seconds in the future).', time() - strtotime($created)));
     }
     // Expire timestamp after 5 minutes
     if (strtotime($created) < time() - 300) {
         throw new WsseAuthenticationException(sprintf('Token created date has expired its 300 seconds of validity (%d seconds).', strtotime($created) - time()));
     }
     // Validate that the nonce is *not* used in the last 10 minutes
     // if it has, this could be a replay attack
     if (file_exists($this->cacheDir . '/' . $nonce) && file_get_contents($this->cacheDir . '/' . $nonce) + 600 > time()) {
         throw new NonceExpiredException('Previously used nonce detected.');
     }
     // If cache directory does not exist we create it
     if (!is_dir($this->cacheDir)) {
         mkdir($this->cacheDir, 0777, true);
     }
     file_put_contents($this->cacheDir . '/' . $nonce, time());
     // Validate Secret
     $expected = base64_encode(sha1(base64_decode($nonce) . $created . $secret, true));
     if (!StringUtils::equals($expected, $digest)) {
         throw new WsseAuthenticationException('Token digest is not valid.');
     }
     return true;
 }
开发者ID:alcalyn,项目名称:symfony-wsse,代码行数:36,代码来源:PasswordDigestValidator.php

示例9: checkAuthentication

 /**
  * {@inheritdoc}
  */
 protected function checkAuthentication(UserInterface $user, UsernamePasswordToken $token)
 {
     $currentUser = $token->getUser();
     if ($currentUser instanceof UserInterface) {
         if ($currentUser->getPassword() !== $user->getPassword()) {
             throw new BadCredentialsException('The credentials were changed from another session.');
         }
     } else {
         if (!($presentedPassword = $token->getCredentials())) {
             throw new BadCredentialsException('The presented password cannot be empty.');
         }
         $client = $this->clientFactory->build('en');
         $request = CustomerLoginRequest::ofEmailAndPassword($token->getUser(), $presentedPassword);
         $response = $request->executeWithClient($client);
         if ($response->isError()) {
             throw new BadCredentialsException('The presented password is invalid.');
         }
         $result = $request->mapResponse($response);
         $customer = $result->getCustomer();
         if ($currentUser !== $customer->getEmail()) {
             throw new BadCredentialsException('The presented password is invalid.');
         }
         $this->session->set('customer.id', $customer->getId());
     }
 }
开发者ID:sphereio,项目名称:commercetools-sunrise-php,代码行数:28,代码来源:CTPAuthenticationProvider.php

示例10: refreshUser

 public function refreshUser(UserInterface $user)
 {
     if (!$user instanceof User) {
         throw new UnsupportedUserException("Instances of {get_class({$user})} are not supported");
     }
     return $this->loadUserByUsername($user->getUsername());
 }
开发者ID:vbessonov,项目名称:fsrapi,代码行数:7,代码来源:UserProvider.php

示例11: refreshUser

 /**
  * {@inheritDoc}
  */
 public function refreshUser(UserInterface $user)
 {
     if (null === ($refreshedUser = $this->repository->findOneByUsername($user->getUsername()))) {
         throw new UsernameNotFoundException(sprintf('User with id %s not found', json_encode($user->getId())));
     }
     return $refreshedUser;
 }
开发者ID:tuimedia,项目名称:forum,代码行数:10,代码来源:OnDemandUserProvider.php

示例12: isGranted

 /**
  * 
  * @param string $attribute
  * @param Club $club
  * @param UserInterface $user
  * @return boolean
  */
 protected function isGranted($attribute, $club, $user = null)
 {
     switch ($attribute) {
         case self::VIEW:
             if (!$club->isPrivate()) {
                 return true;
             }
             // make sure there is a user object (i.e. that the user is logged in)
             if (!$user instanceof UserInterface) {
                 return false;
             }
             if (in_array('ROLE_ADMIN', $user->getRoles())) {
                 return true;
             }
             break;
         case self::EDIT:
             // make sure there is a user object (i.e. that the user is logged in)
             if (!$user instanceof UserInterface) {
                 return false;
             }
             foreach ($club->getAdministrators() as $administrator) {
                 if ($administrator->getId() == $user->getId()) {
                     return true;
                 }
             }
             if (in_array('ROLE_ADMIN', $user->getRoles())) {
                 return true;
             }
             return false;
         case self::CREATE:
             break;
     }
     return false;
 }
开发者ID:oesteve,项目名称:grupeta,代码行数:41,代码来源:ClubVoter.php

示例13: isEqualTo

 public function isEqualTo(UserInterface $user)
 {
     if (!$user instanceof LdapUser || $user->getUsername() !== $this->username || $user->getEmail() !== $this->email || count(array_diff($user->getRoles(), $this->roles)) > 0 || $user->getDn() !== $this->dn) {
         return false;
     }
     return true;
 }
开发者ID:redventures-oss,项目名称:LdapBundle,代码行数:7,代码来源:LdapUser.php

示例14: login

 public function login(UserInterface $user)
 {
     $user->setLastLogin(new \DateTime());
     $this->userManager->updateUser($user);
     $this->loginManager->loginUser($this->providerKey, $user);
     return $user;
 }
开发者ID:xsolve-pl,项目名称:xsolve-google-auth-bundle,代码行数:7,代码来源:FOSUserLoginService.php

示例15: equals

 public function equals(UserInterface $account)
 {
     if ($this->getUsername() == $account->getUsername()) {
         return true;
     }
     return false;
 }
开发者ID:laiello,项目名称:mediathequescrum,代码行数:7,代码来源:User.php


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