コード例 #1
0
ファイル: CreateAccountPage.php プロジェクト: rutgerkok/rCMS
 private function validateInput(User $user, $password1, $password2, UserRepository $userRepo, Text $text)
 {
     $valid = true;
     if (!Validate::username($user->getUsername())) {
         $valid = false;
         $text->addError($text->t("users.the_username") . " " . Validate::getLastError($text));
     }
     if (!Validate::displayName($user->getDisplayName())) {
         $valid = false;
         $text->addError($text->t("users.the_display_name") . " " . Validate::getLastError($text));
     }
     if (!Validate::password($password1, $password2)) {
         $valid = false;
         $text->addError($text->t("users.the_password") . " " . Validate::getLastError($text));
     }
     if (!Validate::email($user->getEmail())) {
         $valid = false;
         $text->addError($text->t("users.the_email") . " " . Validate::getLastError($text));
     }
     if ($userRepo->isUsernameInUse($user->getUsername())) {
         // User with that name already exists
         $valid = false;
         $text->addError($text->tReplaced("errors.already_in_use_on_this_site", $text->t("users.the_username")));
     }
     if (!empty($user->getEmail()) && $userRepo->isEmailInUse($user->getEmail())) {
         // User with that email already exists
         $valid = false;
         $text->addError($text->tReplaced("errors.already_in_use_on_this_site", $text->t("users.the_email")));
     }
     return $valid;
 }
コード例 #2
0
 private function validateInput(User $user, $password, Authentication $auth, UserRepository $userRepo, Text $text)
 {
     $valid = true;
     if (!Validate::username($user->getUsername())) {
         $valid = false;
         $text->addError($text->t("users.the_username") . " " . Validate::getLastError($text));
     }
     if (!Validate::displayName($user->getDisplayName())) {
         $valid = false;
         $text->addError($text->t("users.the_display_name") . " " . Validate::getLastError($text));
     }
     if (!Validate::password($password, $password)) {
         $valid = false;
         $text->addError($text->t("users.the_password") . " " . Validate::getLastError($text));
     }
     if (!Validate::email($user->getEmail())) {
         $valid = false;
         $text->addError($text->t("users.the_email") . " " . Validate::getLastError($text));
     }
     if ($userRepo->isUsernameInUse($user->getUsername())) {
         // User with that name already exists
         $valid = false;
         $text->addError($text->tReplaced("errors.already_in_use_on_this_site", $text->t("users.the_username")));
     }
     if (!empty($user->getEmail()) && $userRepo->isEmailInUse($user->getEmail())) {
         // User with that email already exists
         $valid = false;
         $text->addError($text->tReplaced("errors.already_in_use_on_this_site", $text->t("users.the_email")));
     }
     if (!$auth->isValidRankForAccounts($user->getRank())) {
         // Invlaid rank
         $valid = false;
         $text->addError($text->t("users.the_rank") . " " . $text->t("errors.is_invalid"));
     }
     return $valid;
 }