[FIXED HUDSON-3300] avoid NPE if reach createAccount with no form data

(such as via login?from=/securityRealm/createAccount)


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@16351 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
mindless committed 2009-03-17 16:54:11 +00:00
1 parent 4a664c1ad0
commit f5e60d5cda
1 file changed
+3 -4
@@ -166,7 +166,7 @@ public class HudsonPrivateSecurityRealm extends SecurityRealm implements ModelOb
if(!(si.password1 != null && si.password1.length() != 0))
si.errorMessage = "Password is required";
if(si.username.length()==0)
if(si.username==null || si.username.length()==0)
si.errorMessage = "User name is required";
else {
User user = User.get(si.username);
@@ -174,13 +174,12 @@ public class HudsonPrivateSecurityRealm extends SecurityRealm implements ModelOb
si.errorMessage = "User name is already taken. Did you forget the password?";
}
if(si.fullname.length()==0)
if(si.fullname==null || si.fullname.length()==0)
si.fullname = si.username;
if(!si.email.contains("@"))
if(si.email==null || !si.email.contains("@"))
si.errorMessage = "Invalid e-mail address";
if(si.errorMessage!=null) {
// failed. ask the user to try again.
req.setAttribute("data",si);