提交 463a1c3a 编写于 作者: D Daniel Beck 提交者: Oliver Gondža

[JENKINS-52869] Show error messages on user creation (#3727)

* [JENKINS-52869] Show error messages on user creation

* Restore support for general signup error

(cherry picked from commit 3b8258fd)
上级 73487f6b
......@@ -392,7 +392,7 @@ public class HudsonPrivateSecurityRealm extends AbstractPasswordBasedSecurityRea
* @param validateCaptcha whether to attempt to validate a captcha in the request
*
* @return a {@link SignupInfo#SignupInfo(StaplerRequest) SignupInfo from given request}, with {@link
* SignupInfo#errors} set to a non-null value if any of the supported fields are invalid
* SignupInfo#errors} containing errors (keyed by field name), if any of the supported fields are invalid
*/
private SignupInfo validateAccountCreationForm(StaplerRequest req, boolean validateCaptcha) {
// form field validation
......@@ -554,10 +554,16 @@ public class HudsonPrivateSecurityRealm extends AbstractPasswordBasedSecurityRea
public String username,password1,password2,fullname,email,captcha;
/**
* To display an error message, set it here.
* To display a general error message, set it here.
*
*/
public String errorMessage;
/**
* Add field-specific error messages here.
* Keys are field names (e.g. {@code password2}), values are the messages.
*/
// TODO i18n?
public HashMap<String, String> errors = new HashMap<String, String>();
public SignupInfo() {
......
......@@ -32,6 +32,11 @@ THE SOFTWARE.
${data.errorMessage}
</div>
</j:if>
<j:forEach var="error" items="${data.errors}">
<div class="error" style="margin-bottom:1em">
${error.value}
</div>
</j:forEach>
<table>
<tr>
<td>${%Username}:</td>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册