Fix json integer parsing

This commit is contained in:
colinmcdonald22 2016-10-21 19:36:24 -04:00
parent 525bd64c3b
commit ee3a012f80
10 changed files with 11 additions and 11 deletions

View File

@ -30,7 +30,7 @@ public final class POSTAccessTokens implements Handler<RoutingContext> {
return;
}
int code = requestBody.getInteger("totpCode");
int code = requestBody.getInteger("totpCode", -1);
TotpAuthorizationResult totpAuthorizationResult = SyncUtils.runBlocking(v -> addedBy.checkTotpAuthorization(code, null, v));
if (!totpAuthorizationResult.isAuthorized()) {

View File

@ -16,7 +16,7 @@ public final class POSTBannedAsns implements Handler<RoutingContext> {
public void handle(RoutingContext ctx) {
JsonObject requestBody = ctx.getBodyAsJson();
int id = requestBody.getInteger("id");
int id = requestBody.getInteger("id", -1);
String note = requestBody.getString("note");
BannedAsn bannedAsn = new BannedAsn(id, note);

View File

@ -16,7 +16,7 @@ public final class POSTBannedCellCarriers implements Handler<RoutingContext> {
public void handle(RoutingContext ctx) {
JsonObject requestBody = ctx.getBodyAsJson();
int id = requestBody.getInteger("id");
int id = requestBody.getInteger("id", -1);
String note = requestBody.getString("note");
BannedCellCarrier bannedCellCarrier = new BannedCellCarrier(id, note);

View File

@ -86,7 +86,7 @@ public final class POSTGrants implements Handler<RoutingContext> {
}
if (rank.isGrantRequiresTotp()) {
int code = requestBody.getInteger("totpCode");
int code = requestBody.getInteger("totpCode", -1);
TotpAuthorizationResult totpAuthorizationResult = SyncUtils.runBlocking(v -> addedBy.checkTotpAuthorization(code, null, v));
if (!totpAuthorizationResult.isAuthorized()) {

View File

@ -18,8 +18,8 @@ public final class POSTRanks implements Handler<RoutingContext> {
JsonObject requestBody = ctx.getBodyAsJson();
String id = requestBody.getString("id");
String inheritsFromId = requestBody.getString("inheritsFromId");
int generalWeight = requestBody.getInteger("generalWeight");
int displayWeight = requestBody.getInteger("displayWeight");
int generalWeight = requestBody.getInteger("generalWeight", -1);
int displayWeight = requestBody.getInteger("displayWeight", -1);
String displayName = requestBody.getString("displayName");
String gamePrefix = requestBody.getString("gamePrefix");
String gameColor = requestBody.getString("gameColor");

View File

@ -43,7 +43,7 @@ public final class POSTUsersIdChangePassword implements Handler<RoutingContext>
RequiresTotpResult requiresTotp = SyncUtils.runBlocking(v -> user.requiresTotpAuthorization(null, v));
if (requiresTotp == RequiresTotpResult.REQUIRED_NO_EXEMPTIONS) {
int code = requestBody.getInteger("totpCode");
int code = requestBody.getInteger("totpCode", -1);
TotpAuthorizationResult totpAuthorizationResult = SyncUtils.runBlocking(v -> user.checkTotpAuthorization(code, null, v));
if (!totpAuthorizationResult.isAuthorized()) {

View File

@ -35,7 +35,7 @@ public final class POSTUsersIdConfirmPhone implements Handler<RoutingContext> {
}
JsonObject requestBody = ctx.getBodyAsJson();
int phoneCode = requestBody.getInteger("phoneCode");
int phoneCode = requestBody.getInteger("phoneCode", -1);
if ((System.currentTimeMillis() - user.getPendingPhoneTokenSetAt().toEpochMilli()) > TimeUnit.HOURS.toMillis(6)) {
ErrorUtils.respondOther(ctx, 409, "Phone token is expired", "phoneTokenExpired", ImmutableMap.of());

View File

@ -30,7 +30,7 @@ public final class POSTUsersIdSetupTotp implements Handler<RoutingContext> {
JsonObject requestBody = ctx.getBodyAsJson();
String secret = requestBody.getString("secret");
int totpCode = requestBody.getInteger("totpCode");
int totpCode = requestBody.getInteger("totpCode" -1);
if (TotpUtils.authorizeUser(secret, totpCode)) {
user.setTotpSecret(secret);

View File

@ -38,7 +38,7 @@ public final class POSTUsersIdVerifyTotp implements Handler<RoutingContext> {
return;
}
user.checkTotpAuthorization(requestBody.getInteger("totpCode"), userIp, (totpAuthorizationResult, error2) -> {
user.checkTotpAuthorization(requestBody.getInteger("totpCode", -1), userIp, (totpAuthorizationResult, error2) -> {
if (error2 != null) {
ErrorUtils.respondInternalError(ctx, error2);
return;

View File

@ -16,7 +16,7 @@ public final class ZangResult {
public ZangResult(JsonObject legacy) {
this.phoneNumber = legacy.getString("phone_number");
this.countryCode = legacy.getString("country_code");
this.carrierId = legacy.getInteger("carrier_id");
this.carrierId = legacy.getInteger("carrier_id", -1);
this.network = legacy.getString("network");
this.mobile = Boolean.parseBoolean(legacy.getString("mobile"));
}