From 2bdd54836dcedc5c64be17ace10ab08c118ec2cf Mon Sep 17 00:00:00 2001 From: Colin McDonald Date: Wed, 22 Jun 2016 18:13:09 -0400 Subject: [PATCH] Convert a few routes to use body parameters instead of query params --- .../net/frozenorb/apiv3/route/users/POSTUserRegister.java | 4 +++- .../net/frozenorb/apiv3/route/users/POSTUserVerifyTOTP.java | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/frozenorb/apiv3/route/users/POSTUserRegister.java b/src/main/java/net/frozenorb/apiv3/route/users/POSTUserRegister.java index 2bf43e2..996eb74 100644 --- a/src/main/java/net/frozenorb/apiv3/route/users/POSTUserRegister.java +++ b/src/main/java/net/frozenorb/apiv3/route/users/POSTUserRegister.java @@ -2,6 +2,7 @@ package net.frozenorb.apiv3.route.users; import com.google.common.collect.ImmutableMap; import io.vertx.core.Handler; +import io.vertx.core.json.JsonObject; import io.vertx.ext.web.RoutingContext; import net.frozenorb.apiv3.APIv3; import net.frozenorb.apiv3.model.NotificationTemplate; @@ -36,7 +37,8 @@ public final class POSTUserRegister implements Handler { return; } - String email = ctx.request().getParam("email"); + JsonObject requestBody = ctx.getBodyAsJson(); + String email = requestBody.getString("email"); if (!VALID_EMAIL_PATTERN.matcher(email).matches()) { ErrorUtils.respondInvalidInput(ctx, email + " is not a valid email."); diff --git a/src/main/java/net/frozenorb/apiv3/route/users/POSTUserVerifyTOTP.java b/src/main/java/net/frozenorb/apiv3/route/users/POSTUserVerifyTOTP.java index 4ebaafa..02cbe7a 100644 --- a/src/main/java/net/frozenorb/apiv3/route/users/POSTUserVerifyTOTP.java +++ b/src/main/java/net/frozenorb/apiv3/route/users/POSTUserVerifyTOTP.java @@ -2,6 +2,7 @@ package net.frozenorb.apiv3.route.users; import com.google.common.collect.ImmutableMap; import io.vertx.core.Handler; +import io.vertx.core.json.JsonObject; import io.vertx.ext.web.RoutingContext; import net.frozenorb.apiv3.APIv3; import net.frozenorb.apiv3.model.User; @@ -27,14 +28,15 @@ public final class POSTUserVerifyTotp implements Handler { return; } - String userIp = ctx.request().getParam("userIp"); + JsonObject requestBody = ctx.getBodyAsJson(); + String userIp = requestBody.getString("userIp"); if (!IpUtils.isValidIp(userIp)) { ErrorUtils.respondInvalidInput(ctx, "Ip address \"" + userIp + "\" is not valid."); return; } - int providedCode = Integer.parseInt(ctx.request().getParam("code")); + int providedCode = requestBody.getInteger("code"); BlockingCallback recentlyUsedCallback = new BlockingCallback<>(); TotpUtils.wasRecentlyUsed(user, providedCode, recentlyUsedCallback);