Fix json integer parsing
This commit is contained in:
parent
525bd64c3b
commit
ee3a012f80
@ -30,7 +30,7 @@ public final class POSTAccessTokens implements Handler<RoutingContext> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int code = requestBody.getInteger("totpCode");
|
int code = requestBody.getInteger("totpCode", -1);
|
||||||
TotpAuthorizationResult totpAuthorizationResult = SyncUtils.runBlocking(v -> addedBy.checkTotpAuthorization(code, null, v));
|
TotpAuthorizationResult totpAuthorizationResult = SyncUtils.runBlocking(v -> addedBy.checkTotpAuthorization(code, null, v));
|
||||||
|
|
||||||
if (!totpAuthorizationResult.isAuthorized()) {
|
if (!totpAuthorizationResult.isAuthorized()) {
|
||||||
|
@ -16,7 +16,7 @@ public final class POSTBannedAsns implements Handler<RoutingContext> {
|
|||||||
|
|
||||||
public void handle(RoutingContext ctx) {
|
public void handle(RoutingContext ctx) {
|
||||||
JsonObject requestBody = ctx.getBodyAsJson();
|
JsonObject requestBody = ctx.getBodyAsJson();
|
||||||
int id = requestBody.getInteger("id");
|
int id = requestBody.getInteger("id", -1);
|
||||||
String note = requestBody.getString("note");
|
String note = requestBody.getString("note");
|
||||||
|
|
||||||
BannedAsn bannedAsn = new BannedAsn(id, note);
|
BannedAsn bannedAsn = new BannedAsn(id, note);
|
||||||
|
@ -16,7 +16,7 @@ public final class POSTBannedCellCarriers implements Handler<RoutingContext> {
|
|||||||
|
|
||||||
public void handle(RoutingContext ctx) {
|
public void handle(RoutingContext ctx) {
|
||||||
JsonObject requestBody = ctx.getBodyAsJson();
|
JsonObject requestBody = ctx.getBodyAsJson();
|
||||||
int id = requestBody.getInteger("id");
|
int id = requestBody.getInteger("id", -1);
|
||||||
String note = requestBody.getString("note");
|
String note = requestBody.getString("note");
|
||||||
|
|
||||||
BannedCellCarrier bannedCellCarrier = new BannedCellCarrier(id, note);
|
BannedCellCarrier bannedCellCarrier = new BannedCellCarrier(id, note);
|
||||||
|
@ -86,7 +86,7 @@ public final class POSTGrants implements Handler<RoutingContext> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (rank.isGrantRequiresTotp()) {
|
if (rank.isGrantRequiresTotp()) {
|
||||||
int code = requestBody.getInteger("totpCode");
|
int code = requestBody.getInteger("totpCode", -1);
|
||||||
TotpAuthorizationResult totpAuthorizationResult = SyncUtils.runBlocking(v -> addedBy.checkTotpAuthorization(code, null, v));
|
TotpAuthorizationResult totpAuthorizationResult = SyncUtils.runBlocking(v -> addedBy.checkTotpAuthorization(code, null, v));
|
||||||
|
|
||||||
if (!totpAuthorizationResult.isAuthorized()) {
|
if (!totpAuthorizationResult.isAuthorized()) {
|
||||||
|
@ -18,8 +18,8 @@ public final class POSTRanks implements Handler<RoutingContext> {
|
|||||||
JsonObject requestBody = ctx.getBodyAsJson();
|
JsonObject requestBody = ctx.getBodyAsJson();
|
||||||
String id = requestBody.getString("id");
|
String id = requestBody.getString("id");
|
||||||
String inheritsFromId = requestBody.getString("inheritsFromId");
|
String inheritsFromId = requestBody.getString("inheritsFromId");
|
||||||
int generalWeight = requestBody.getInteger("generalWeight");
|
int generalWeight = requestBody.getInteger("generalWeight", -1);
|
||||||
int displayWeight = requestBody.getInteger("displayWeight");
|
int displayWeight = requestBody.getInteger("displayWeight", -1);
|
||||||
String displayName = requestBody.getString("displayName");
|
String displayName = requestBody.getString("displayName");
|
||||||
String gamePrefix = requestBody.getString("gamePrefix");
|
String gamePrefix = requestBody.getString("gamePrefix");
|
||||||
String gameColor = requestBody.getString("gameColor");
|
String gameColor = requestBody.getString("gameColor");
|
||||||
|
@ -43,7 +43,7 @@ public final class POSTUsersIdChangePassword implements Handler<RoutingContext>
|
|||||||
RequiresTotpResult requiresTotp = SyncUtils.runBlocking(v -> user.requiresTotpAuthorization(null, v));
|
RequiresTotpResult requiresTotp = SyncUtils.runBlocking(v -> user.requiresTotpAuthorization(null, v));
|
||||||
|
|
||||||
if (requiresTotp == RequiresTotpResult.REQUIRED_NO_EXEMPTIONS) {
|
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));
|
TotpAuthorizationResult totpAuthorizationResult = SyncUtils.runBlocking(v -> user.checkTotpAuthorization(code, null, v));
|
||||||
|
|
||||||
if (!totpAuthorizationResult.isAuthorized()) {
|
if (!totpAuthorizationResult.isAuthorized()) {
|
||||||
|
@ -35,7 +35,7 @@ public final class POSTUsersIdConfirmPhone implements Handler<RoutingContext> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
JsonObject requestBody = ctx.getBodyAsJson();
|
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)) {
|
if ((System.currentTimeMillis() - user.getPendingPhoneTokenSetAt().toEpochMilli()) > TimeUnit.HOURS.toMillis(6)) {
|
||||||
ErrorUtils.respondOther(ctx, 409, "Phone token is expired", "phoneTokenExpired", ImmutableMap.of());
|
ErrorUtils.respondOther(ctx, 409, "Phone token is expired", "phoneTokenExpired", ImmutableMap.of());
|
||||||
|
@ -30,7 +30,7 @@ public final class POSTUsersIdSetupTotp implements Handler<RoutingContext> {
|
|||||||
|
|
||||||
JsonObject requestBody = ctx.getBodyAsJson();
|
JsonObject requestBody = ctx.getBodyAsJson();
|
||||||
String secret = requestBody.getString("secret");
|
String secret = requestBody.getString("secret");
|
||||||
int totpCode = requestBody.getInteger("totpCode");
|
int totpCode = requestBody.getInteger("totpCode" -1);
|
||||||
|
|
||||||
if (TotpUtils.authorizeUser(secret, totpCode)) {
|
if (TotpUtils.authorizeUser(secret, totpCode)) {
|
||||||
user.setTotpSecret(secret);
|
user.setTotpSecret(secret);
|
||||||
|
@ -38,7 +38,7 @@ public final class POSTUsersIdVerifyTotp implements Handler<RoutingContext> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
user.checkTotpAuthorization(requestBody.getInteger("totpCode"), userIp, (totpAuthorizationResult, error2) -> {
|
user.checkTotpAuthorization(requestBody.getInteger("totpCode", -1), userIp, (totpAuthorizationResult, error2) -> {
|
||||||
if (error2 != null) {
|
if (error2 != null) {
|
||||||
ErrorUtils.respondInternalError(ctx, error2);
|
ErrorUtils.respondInternalError(ctx, error2);
|
||||||
return;
|
return;
|
||||||
|
@ -16,7 +16,7 @@ public final class ZangResult {
|
|||||||
public ZangResult(JsonObject legacy) {
|
public ZangResult(JsonObject legacy) {
|
||||||
this.phoneNumber = legacy.getString("phone_number");
|
this.phoneNumber = legacy.getString("phone_number");
|
||||||
this.countryCode = legacy.getString("country_code");
|
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.network = legacy.getString("network");
|
||||||
this.mobile = Boolean.parseBoolean(legacy.getString("mobile"));
|
this.mobile = Boolean.parseBoolean(legacy.getString("mobile"));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user