Convert a few routes to use body parameters instead of query params
This commit is contained in:
parent
152492eb06
commit
2bdd54836d
@ -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<RoutingContext> {
|
||||
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.");
|
||||
|
@ -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<RoutingContext> {
|
||||
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<Boolean> recentlyUsedCallback = new BlockingCallback<>();
|
||||
TotpUtils.wasRecentlyUsed(user, providedCode, recentlyUsedCallback);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user