diff --git a/src/main/java/net/frozenorb/apiv3/route/users/GETUsersIdRequiresTotp.java b/src/main/java/net/frozenorb/apiv3/route/users/GETUsersIdRequiresTotp.java index c1342c2..61df223 100644 --- a/src/main/java/net/frozenorb/apiv3/route/users/GETUsersIdRequiresTotp.java +++ b/src/main/java/net/frozenorb/apiv3/route/users/GETUsersIdRequiresTotp.java @@ -25,7 +25,7 @@ public final class GETUsersIdRequiresTotp implements Handler { String userIp = ctx.request().getParam("userIp"); - if (!IpUtils.isValidIp(userIp)) { + if (userIp != null && IpUtils.isValidIp(userIp)) { ErrorUtils.respondInvalidInput(ctx, "Ip address \"" + userIp + "\" is not valid."); return; } diff --git a/src/main/java/net/frozenorb/apiv3/route/users/POSTUsersIdSetupTotp.java b/src/main/java/net/frozenorb/apiv3/route/users/POSTUsersIdSetupTotp.java index 30a4e48..6e8eeef 100644 --- a/src/main/java/net/frozenorb/apiv3/route/users/POSTUsersIdSetupTotp.java +++ b/src/main/java/net/frozenorb/apiv3/route/users/POSTUsersIdSetupTotp.java @@ -45,13 +45,12 @@ public final class POSTUsersIdSetupTotp implements Handler { ErrorUtils.respondInternalError(ctx, error); } else { APIv3.respondJson(ctx, 200, ImmutableMap.of( - "success", true, - "message", "Totp code set." + "success", true )); } }); } else { - ErrorUtils.respondInvalidInput(ctx, "Confirmation code provided did not match."); + ErrorUtils.respondOther(ctx, 400, "Confirmation code provided did not match.", "badConfirmationCode", ImmutableMap.of()); } } diff --git a/src/main/java/net/frozenorb/apiv3/util/ErrorUtils.java b/src/main/java/net/frozenorb/apiv3/util/ErrorUtils.java index e47a5b2..a1aeaa5 100644 --- a/src/main/java/net/frozenorb/apiv3/util/ErrorUtils.java +++ b/src/main/java/net/frozenorb/apiv3/util/ErrorUtils.java @@ -17,7 +17,7 @@ public class ErrorUtils { } public static void respondInvalidInput(RoutingContext ctx, String message) { - respond(ctx, 400, "Invalid input: " + message + ".", null, null); + respond(ctx, 400, "Invalid input: " + message, null, null); } public static void respondRequiredInput(RoutingContext ctx, String field) { diff --git a/src/main/java/net/frozenorb/apiv3/util/PhoneUtils.java b/src/main/java/net/frozenorb/apiv3/util/PhoneUtils.java index 116e65d..443655b 100644 --- a/src/main/java/net/frozenorb/apiv3/util/PhoneUtils.java +++ b/src/main/java/net/frozenorb/apiv3/util/PhoneUtils.java @@ -8,7 +8,7 @@ import java.util.regex.Pattern; public class PhoneUtils { private static final Pattern VALID_PHONE_PATTERN = Pattern.compile( - "^(+1|1)?([2-9]\\d\\d[2-9]\\d{6})$", + "^\\+?[1-9]\\d{1,14}$", Pattern.CASE_INSENSITIVE );