setPlainPassword() 공개 메소드

public setPlainPassword ( $password )
예제 #1
0
 /**
  * Set user data using shibboleth heders as data source
  *
  * @param \FOS\UserBundle\Entity\User                             $user
  * @param \KULeuven\ShibbolethBundle\Security\ShibbolethUserToken $token
  */
 private function setUserData(BaseUser $user, ShibbolethUserToken $token)
 {
     if ($user instanceof User) {
         $user->setGivenName($token->getGivenName());
         $user->setSurname($token->getSurname());
     }
     $user->setPlainPassword('no_passwd');
     if (null != $token->getMail()) {
         $user->setEmail($token->getMail());
     } else {
         $user->setEmail($token->getUsername() . '@kuleuven.be');
     }
     if ($token->isStudent()) {
         $user->addRole('ROLE_STUDENT');
     } elseif ($token->isStaff()) {
         $user->addRole('ROLE_STAFF');
     } else {
         $user->addRole('ROLE_GUEST');
     }
     $user->addRole('ROLE_USER');
     $user->setEnabled(true);
     $this->userManager->updateUser($user);
 }
예제 #2
0
 /**
  * Set user data using imap data source
  *
  * @param \FOS\UserBundle\Entity\User                             $user
  * @param \Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken $token
  */
 private function setUserData(BaseUser $user, UsernamePasswordToken $token)
 {
     $parts = $this->emailParser->parse($user->getUsername());
     $this->verifyDomain($parts['domain']);
     $localPart = $parts['local'];
     $unumber = str_replace('u', '', $localPart);
     $url = "http://www.kuleuven.be/wieiswie/en/person/" . $unumber;
     $ch = curl_init();
     $timeout = 5;
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
     $html = curl_exec($ch);
     curl_close($ch);
     $dom = new \DOMDocument();
     @$dom->loadHTML($html);
     $uname = "";
     foreach ($dom->getElementsByTagName('h1') as $h1) {
         $uname = $h1->nodeValue;
     }
     $uemail = "";
     foreach ($dom->getElementsByTagName('script') as $script) {
         $emailPre = trim($script->nodeValue);
         if (!empty($emailPre)) {
             $emailPre = str_replace('document.write(String.fromCharCode(', '', $emailPre);
             $emailPre = str_replace('))', '', $emailPre);
             $emailArray = explode(',', $emailPre);
             $emailLink = "";
             foreach ($emailArray as $element) {
                 $emailLink .= chr(eval('return ' . $element . ';'));
             }
             $domInner = new \DOMDocument();
             @$domInner->loadHTML($emailLink);
             foreach ($domInner->getElementsByTagName('a') as $a) {
                 $uemail = $a->nodeValue;
             }
         }
     }
     $names = explode(" ", $uname);
     $mailparts = $this->emailParser->parse($uemail);
     $mailuname = $mailparts['local'];
     $mailnames = explode(".", $mailuname);
     $surnameIndex = 0;
     foreach ($names as $index => $name) {
         if (strtolower(substr($mailnames[1], 0, strlen($name))) === strtolower($name)) {
             $surnameIndex = $index;
         }
     }
     if ($user instanceof User) {
         $givenName = implode(" ", array_slice($names, 0, $surnameIndex));
         $user->setGivenName($givenName);
         $lastName = implode(" ", array_slice($names, $surnameIndex));
         $user->setSurname($lastName);
     }
     $user->setEmail($uemail);
     $user->setPlainPassword($this->generateRandomString());
     $user->addRole('ROLE_USER');
     $user->addRole('ROLE_KULEUVEN');
     $user->setEnabled(true);
     $this->userManager->updateUser($user);
 }
예제 #3
0
 public function setPlainPassword($password)
 {
     parent::setPlainPassword($password);
     $this->password = $password;
     return $this;
 }
예제 #4
0
파일: User.php 프로젝트: symbb/symbb
 /**
  * @param string $pw
  */
 public function setPlainPassword($pw)
 {
     if (!empty($pw)) {
         parent::setPlainPassword($pw);
         $this->changed = new \DateTime();
     }
 }
예제 #5
0
파일: User.php 프로젝트: trivago-tgoik/kis
 public function setPlainPassword($password)
 {
     $keyPair = KeyGen::generateKeyPair($password);
     $this->setPrivateKey($keyPair->privateKey);
     $this->setPublicKey($keyPair->publicKey);
     parent::setPlainPassword($password);
 }
예제 #6
0
 /**
  * Set user data using imap data source
  *
  * @param \FOS\UserBundle\Entity\User                             $user
  * @param \Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken $token
  */
 private function setUserData(BaseUser $user, UsernamePasswordToken $token)
 {
     $email = $user->getUsername();
     $parts = $this->emailParser->parse($email);
     $this->verifyDomain($parts['domain']);
     $userNameArray = explode('.', $parts['local']);
     if ($user instanceof User) {
         $givenName = ucfirst($userNameArray[0]);
         $user->setGivenName($givenName);
         $lastName = ucfirst($userNameArray[1]);
         $user->setSurname($lastName);
     }
     $user->setEmail($email);
     $user->setPlainPassword($this->generateRandomString());
     $user->addRole('ROLE_USER');
     $user->addRole('ROLE_ICM');
     $user->setEnabled(true);
     $this->userManager->updateUser($user);
 }