PAN-54
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package edu.msudenver.tsp.website.controller;
|
||||
|
||||
import edu.msudenver.tsp.website.forms.UserCreationForm;
|
||||
|
||||
import javax.validation.ConstraintValidatorContext;
|
||||
|
||||
public class ConfirmPasswordValidator
|
||||
implements ConstraintValidator<PasswordMatchChecker, Object> {
|
||||
|
||||
@Override
|
||||
public void initialize(final PasswordMatchChecker constraintAnnotation) {
|
||||
}
|
||||
@Override
|
||||
public boolean isValid(final Object obj, final ConstraintValidatorContext context) {
|
||||
final UserCreationForm user = (UserCreationForm) obj;
|
||||
return user.getPassword().equals(user.getConfirmPassword());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package edu.msudenver.tsp.website.controller;
|
||||
|
||||
import javax.validation.Constraint;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target({TYPE,ANNOTATION_TYPE})
|
||||
@Retention(RUNTIME)
|
||||
@Constraint(validatedBy = ConfirmPasswordValidator.class)
|
||||
@Documented
|
||||
public @interface PasswordMatchChecker {
|
||||
String message() default "Passwords don't match";
|
||||
Class<?>[] groups() default {};
|
||||
Class<? extends Payload>[] payload() default {};
|
||||
}
|
||||
@@ -27,6 +27,7 @@ public class UserCreationController {
|
||||
model.addAttribute("userID", userCreationForm.getUserID());
|
||||
model.addAttribute("username", userCreationForm.getUsername());
|
||||
model.addAttribute("password", userCreationForm.getPassword());
|
||||
model.addAttribute("confirmPassword", userCreationForm.getConfirmPassword());
|
||||
model.addAttribute("emailAddress", userCreationForm.getEmailAddress());
|
||||
model.addAttribute("firstName", userCreationForm.getFirstName());
|
||||
model.addAttribute("lastName", userCreationForm.getLastName());
|
||||
|
||||
@@ -3,16 +3,50 @@ package edu.msudenver.tsp.website.forms;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class UserCreationForm {
|
||||
@NotNull
|
||||
@NotEmpty
|
||||
private int userID;
|
||||
|
||||
@NotNull
|
||||
@NotEmpty
|
||||
private String username;
|
||||
|
||||
@NotNull
|
||||
@NotEmpty
|
||||
private String password;
|
||||
|
||||
@NotNull
|
||||
@NotEmpty
|
||||
private String confirmPassword;
|
||||
|
||||
public Boolean checkPassword(final String passwordInput, final String passwordCheck) {
|
||||
if(!passwordInput.equals(passwordCheck)) {
|
||||
return false;
|
||||
}
|
||||
else return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@NotEmpty
|
||||
private String emailAddress;
|
||||
|
||||
@NotNull
|
||||
@NotEmpty
|
||||
private String firstName;
|
||||
|
||||
@NotNull
|
||||
@NotEmpty
|
||||
private String lastName;
|
||||
|
||||
private String referrer; // optional
|
||||
|
||||
@NotNull
|
||||
@NotEmpty
|
||||
private boolean agreedToTerms;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user