コード例 #1
0
ファイル: UserIndex.java プロジェクト: j0hj0h/oerworldmap
  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));
  }
コード例 #2
0
ファイル: UserIndex.java プロジェクト: j0hj0h/oerworldmap
 @Security.Authenticated(Secured.class)
 public static Result deleteToken() {
   Resource user = new Resource("Person");
   user.put("email", request().username());
   Account.removeTokenFor(user);
   List<Map<String, Object>> messages = new ArrayList<>();
   HashMap<String, Object> message = new HashMap<>();
   message.put("level", "success");
   message.put("message", i18n.get("user_token_delete_feedback"));
   messages.add(message);
   return ok(render("Delete Token", "feedback.mustache", user, messages));
 }
コード例 #3
0
ファイル: UserIndex.java プロジェクト: j0hj0h/oerworldmap
  public static Result sendToken() {
    Resource user = Resource.fromJson(JSONForm.parseFormData(request().body().asFormUrlEncoded()));
    ProcessingReport report = user.validate();
    if (!report.isSuccess()) {
      return badRequest(
          render(
              "Request Token",
              "Secured/token.mustache",
              user,
              JSONForm.generateErrorReport(report)));
    }
    String token = Account.createTokenFor(user);
    sendTokenMail(user, token);

    List<Map<String, Object>> messages = new ArrayList<>();
    HashMap<String, Object> message = new HashMap<>();
    message.put("level", "success");
    message.put("message", i18n.get("user_token_request_feedback"));
    messages.add(message);
    return ok(render("Request Token", "feedback.mustache", user, messages));
  }