/** * Gets the error message to display on the login form, like "Wrong * password" or "You need to be logged in to view this page". * @param Text $text The text object, used for translations. * @param Authentication $oAuth The authentication object. * @return string The error message, or empty if there is no message. */ protected function getLoginErrorMessage(Text $text, Authentication $oAuth) { if ($oAuth->hasLoginFailed()) { return $text->t("errors.invalid_login_credentials"); } return ""; }
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; }
protected function get_statuses_box_html(Authentication $oAuth, $statuss, $selected) { $selection_box = '<select name="status" id="status">'; foreach ($statuss as $id) { $label = $oAuth->getStatusName($id); $selection_box .= '<option value="' . $id . '"'; if ($selected == $id) { $selection_box .= ' selected="selected"'; } $selection_box .= '>' . $label . "</option>\n"; } $selection_box .= "</select>\n"; return $selection_box; }