예제 #1
0
 public function resetPassword($username, $link)
 {
     $newHash = PasswordHelper::getInstance()->createUniqueHash();
     $admin = GenericDatabaseService::getInstance()->getSingle(new UserModel(), array("Username" => $username));
     if ($admin instanceof UserModel) {
         $admin->setAuthHash($newHash);
         GenericDatabaseService::getInstance()->update($admin, array("Id", "AuthHash"));
         return EmailService::getInstance()->sendEmailFromServer(LocaleService::getInstance()->translate("password reset"), LocaleService::getInstance()->translate("your password was reset. click following link to set a new one: "), LocaleService::getInstance()->translate("your password "));
     }
     return false;
 }
예제 #2
0
 private function getFormToken($action)
 {
     $params = explode("/", $action);
     if ($params[count($params) - 1] == "create") {
         return $this->getHiddenKeyValue("create", "true");
     }
     $allowed = array("update", "delete");
     if (is_numeric($params[count($params) - 1]) || PasswordHelper::getInstance()->checkIfHashIsValid($params[count($params) - 1])) {
         if (in_array($params[count($params) - 2], $allowed)) {
             return $this->getHiddenKeyValue($params[count($params) - 2], "true");
         }
     } else {
         return $this->getHiddenKeyValue($params[count($params) - 1], "true");
     }
     return "";
 }
예제 #3
0
 private function canSetPassword(LoginDatabaseModel $model)
 {
     if ($model->getPassword() != $model->getConfirmPassword()) {
         LogHelper::getInstance()->logUserError("passwords do not match");
         return false;
     }
     $failure = PasswordHelper::getInstance()->checkPassword($model->getPassword());
     if ($failure !== true) {
         LogHelper::getInstance()->logUserError(PasswordHelper::getInstance()->evaluateFailure($failure));
         return false;
     }
     return true;
 }