예제 #1
0
  public boolean validate(String email) {
    if (users.existsWithEmail(email)) {
      validator.add(messageFactory.build("error", "user.errors.email.used"));
    }
    if (email == null) {
      validator.add(messageFactory.build("error", "user.errors.email.required"));
    }

    return !validator.hasErrors();
  }
예제 #2
0
 @Override
 public void handle() {
   if ("application/json".equals(req.getHeader("Accept"))) {
     result.use(Results.http()).body(bundle.getMessage("error.requires_login")).sendError(403);
   } else {
     result.include("messages", asList(messageFactory.build("alert", "auth.access.denied")));
     String redirectUrl = req.getRequestURL().toString();
     result.redirectTo(AuthController.class).loginForm(redirectUrl);
   }
 }