Beispiel #1
0
 /**
  * Hash a password from $user->getPassword()
  *
  * @param User $user
  * @param string $method "md5", "sha1" or "none"
  * @return void
  */
 public static function hashPassword(User &$user, $method)
 {
     switch ($method) {
         case 'none':
             break;
         case 'md5':
             $user->setPassword(md5($user->getPassword()));
             break;
         case 'sha1':
             $user->setPassword(sha1($user->getPassword()));
             break;
         default:
             if (ExtensionManagementUtility::isLoaded('saltedpasswords')) {
                 if (SaltedPasswordsUtility::isUsageEnabled('FE')) {
                     $objInstanceSaltedPw = SaltFactory::getSaltingInstance();
                     $user->setPassword($objInstanceSaltedPw->getHashedPassword($user->getPassword()));
                 }
             }
     }
 }