Beispiel #1
0
 public function setPassword($value, $key = NULL)
 {
     if (is_null($value)) {
         $this->password = NULL;
     } else {
         if (!$this->username) {
             // Without username you can't set the password
             $this->tempPass = $this->password = $value;
         } else {
             $newPass = Encrypt::hashPassword($value);
             $this->password = NULL;
             $this->get('password');
             if ($this->password != $newPass) {
                 // Only fiddle with the key if it's a change in password (prevents multiple passes)
                 $this->password = $newPass;
                 if (!$key) {
                     // Allow a key to be sent with the setPassword
                     $key = $this->getKey();
                 }
                 if ($key) {
                     $td = new Encrypt($value);
                     $this->dbkey = $td->encrypt($key);
                 }
             }
             unset($this->tempPass);
         }
     }
 }