Esempio n. 1
0
  public static Result post() throws IOException {

    Resource user = Resource.fromJson(JSONForm.parseFormData(request().body().asFormUrlEncoded()));
    Map<String, Object> scope = new HashMap<>();

    ProcessingReport report = user.validate();
    user.put("mbox_sha1sum", Account.getEncryptedEmailAddress(user));
    if (mConf.getBoolean("user.email.unique")) {
      ensureEmailUnique(user, report);
    }
    if (!report.isSuccess()) {
      scope.put("countries", Countries.list(currentLocale));
      scope.put("user", user);
      return badRequest(
          render(
              "Registration",
              "UserIndex/index.mustache",
              scope,
              JSONForm.generateErrorReport(report)));
    }

    newsletterSignup(user);
    user.remove("email");
    mBaseRepository.addResource(user);

    List<Map<String, Object>> messages = new ArrayList<>();
    HashMap<String, Object> message = new HashMap<>();
    message.put("level", "success");
    message.put("message", i18n.get("user_registration_feedback"));
    messages.add(message);
    return ok(render("Registration", "feedback.mustache", scope, messages));
  }
Esempio n. 2
0
 public static Result get() throws IOException {
   Map<String, Object> scope = new HashMap<>();
   scope.put("countries", Countries.list(currentLocale));
   return ok(render("Registration", "UserIndex/index.mustache", scope));
 }