Small changes discovered while writing documentation
This commit is contained in:
parent
85b98b4a1d
commit
7bb1b17575
@ -25,7 +25,7 @@ public final class GETUsersIdRequiresTotp implements Handler<RoutingContext> {
|
|||||||
|
|
||||||
String userIp = ctx.request().getParam("userIp");
|
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.");
|
ErrorUtils.respondInvalidInput(ctx, "Ip address \"" + userIp + "\" is not valid.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -45,13 +45,12 @@ public final class POSTUsersIdSetupTotp implements Handler<RoutingContext> {
|
|||||||
ErrorUtils.respondInternalError(ctx, error);
|
ErrorUtils.respondInternalError(ctx, error);
|
||||||
} else {
|
} else {
|
||||||
APIv3.respondJson(ctx, 200, ImmutableMap.of(
|
APIv3.respondJson(ctx, 200, ImmutableMap.of(
|
||||||
"success", true,
|
"success", true
|
||||||
"message", "Totp code set."
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
ErrorUtils.respondInvalidInput(ctx, "Confirmation code provided did not match.");
|
ErrorUtils.respondOther(ctx, 400, "Confirmation code provided did not match.", "badConfirmationCode", ImmutableMap.of());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ public class ErrorUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void respondInvalidInput(RoutingContext ctx, String message) {
|
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) {
|
public static void respondRequiredInput(RoutingContext ctx, String field) {
|
||||||
|
@ -8,7 +8,7 @@ import java.util.regex.Pattern;
|
|||||||
public class PhoneUtils {
|
public class PhoneUtils {
|
||||||
|
|
||||||
private static final Pattern VALID_PHONE_PATTERN = Pattern.compile(
|
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
|
Pattern.CASE_INSENSITIVE
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user