getUsernameCanonical() public method

Ejemplo n.º 1
0
 /**
  * Enforces that the given user will have an username
  * @param \FOS\UserBundle\Model\UserInterface $user
  */
 public function enforceUsername(UserInterface $user)
 {
     $current = $user->getUsernameCanonical();
     if (is_null($current) || strlen($current) == 0) {
         $email = explode('@', $user->getEmailCanonical(), 2);
         $username = $email[0];
         if (!UsernameValidator::isUsernameValid($username)) {
             $username = UsernameValidator::getValidUsername();
         }
         $newUsername = $this->getNextAvailableUsername($username);
         $user->setUsername($newUsername);
         $this->updateCanonicalFields($user);
     }
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function updatePassword(UserInterface $user)
 {
     if (0 !== strlen($password = $user->getPlainPassword())) {
         $passwordDigesta = md5($user->getUsernameCanonical() . ':SabreDAV:' . $password);
         $salt = $user->getSalt();
         $salted = $password . '{' . $salt . '}';
         $digest = hash('sha512', $salted, true);
         for ($i = 1; $i < 5000; $i++) {
             $digest = hash('sha512', $digest . $salted, true);
         }
         $encodedPassword = base64_encode($digest);
         $user->setPassword($encodedPassword);
         $user->setPasswordDigesta($passwordDigesta);
         $user->eraseCredentials();
     }
 }