protected final void saveFormError(final Form<?> form, final String message) { form.reject(message); }
/** * Adds an error to this form. * * @param key the error key * @param error the error message */ public void reject(String key, String error) { reject(key, error, new ArrayList<Object>()); }
/** * Add a global error to this form. * * @param error the error message. */ public void reject(String error) { reject("", error, new ArrayList<Object>()); }
/** * Add a global error to this form. * * @param error the error message. */ public void reject(String error) { reject("", error, new ArrayList<Object>()); }
/** * Adds an error to this form. * * @param key the error key * @param error the error message */ public void reject(String key, String error) { reject(key, error, new ArrayList<Object>()); }
protected final void saveUnexpectedFormError(final Form<?> form, final Throwable throwable, final Logger logger) { form.reject("messages:defaultError"); logger.error("The CTP request raised an unexpected exception", throwable); } }
/** * Adds an error to this form. * * @param key the error key * @param error the error message */ public void reject(String key, String error) { super.reject(asDynamicKey(key), error); }
/** * Adds an error to this form. * * @param key the error key * @param error the error message * @param args the errot arguments */ public void reject(String key, String error, List<Object> args) { super.reject(asDynamicKey(key), error, args); }
/** * Adds a global error to this form. * * @param error the error message * @param args the errot arguments */ public void reject(String error, List<Object> args) { reject(new ValidationError("", error, args)); }
/** * Adds an error to this form. * * @param key the error key * @param error the error message * @param args the errot arguments */ public void reject(String key, String error, List<Object> args) { reject(new ValidationError(key, error, args)); }
/** * Adds an error to this form. * * @param key the error key * @param error the error message * @param args the error arguments */ public void reject(String key, String error, List<Object> args) { reject(new ValidationError(key, error, args)); }
/** * Adds a global error to this form. * * @param error the error message * @param args the errot arguments */ public void reject(String error, List<Object> args) { reject(new ValidationError("", error, args)); }
/** * Adds an error to this form. * * @param key the error key * @param error the error message * @param args the errot arguments */ public void reject(String key, String error, List<Object> args) { super.reject(asDynamicKey(key), error, args); }
/** * Adds an error to this form. * * @param key the error key * @param error the error message */ public void reject(String key, String error) { super.reject(asDynamicKey(key), error); }
private static boolean isPasswordConfirmationCorrect(Form<PasswordResetData> form) { if (form.get().passwordsMatch()) { return true; } else { form.reject(PasswordResetData.PASSWORD_CONFIRMATION_FIELD, SignupService.PASSWORDS_MISMATCH); return false; } }
protected static boolean isPasswordConfirmationCorrect(Form<SignupData> signUpForm) { String password = signUpForm.get().getPassword(); String passwordConfirmation = signUpForm.get().getPasswordConfirmation(); if (!password.equals(passwordConfirmation)) { signUpForm.reject(SignupData.PASSWORD_CONFIRMATION_FIELD, PASSWORDS_MISMATCH); return false; } return true; }
protected static boolean isUsernameFree(Form<SignupData> signUpForm) { String username = signUpForm.get().getUsername(); if (username != null && userRepository().findUserByUsername(username) != null) { signUpForm.reject(SignupData.USERNAME_FIELD, "A user with the given username is already signed up."); return false; } return true; }
protected static boolean isEmailFree(Form<SignupData> signUpForm) { String email = signUpForm.get().getEmail(); if (userRepository().findUserByEmail(email) != null) { signUpForm.reject(SignupData.EMAIL_FIELD, "A user with the given email is already signed up."); return false; } return true; }
private static boolean tryResetPassword(Form<PasswordResetData> form) { PasswordResetData passwordResetData = form.get(); boolean passwordResetSucceeded = tryResetPassword(passwordResetData.getEmail(), passwordResetData.getResetPasswordToken(), passwordResetData.getPassword()); if (passwordResetSucceeded) { return true; } else { form.reject(PasswordResetData.PASSWORD_CONFIRMATION_FIELD, PASSWORD_RESET_ERROR); return false; } }
public boolean tryLogIn(Form<?> loginForm) { String email = loginForm.field(EMAIL_FIELD).value(); String password = loginForm.field(PASSWORD_FIELD).value(); PlessUser authenticatedUser = passwordAuthenticator().tryAuthenticateUser(email, password); if (authenticatedUser != null) { authenticationService().logIn(authenticatedUser); return true; } loginForm.reject(EMAIL_FIELD, "Login failed due to an incorrect email or password."); return false; }