From 186b0361c239c8265826f4c1e0e9143aef3efef8 Mon Sep 17 00:00:00 2001 From: danilodominguezperez Date: Wed, 11 Aug 2021 10:36:53 -0500 Subject: [PATCH] Use compromised password body so default case is invalid account Instead of checking for something different to "invalid account", check directly for "compromised password" body string so if we get something different it goes to the default case. --- .../src/main/java/com/simperium/client/AuthException.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Simperium/src/main/java/com/simperium/client/AuthException.java b/Simperium/src/main/java/com/simperium/client/AuthException.java index e870f76..f8c76ff 100644 --- a/Simperium/src/main/java/com/simperium/client/AuthException.java +++ b/Simperium/src/main/java/com/simperium/client/AuthException.java @@ -9,7 +9,7 @@ public class AuthException extends SimperiumException { static public final String GENERIC_FAILURE_MESSAGE = "Invalid username or password"; static public final String EXISTING_USER_FAILURE_MESSAGE = "Account already exists"; static public final String COMPROMISED_PASSWORD_MESSAGE = "Password has been compromised"; - static public final String INVALID_LOGIN_BODY = "invalid login"; + static public final String COMPROMISED_PASSWORD_BODY = "compromised password"; static public final int ERROR_STATUS_CODE = -1; @@ -44,7 +44,7 @@ public static AuthException exceptionForStatusCode(int statusCode, Throwable cau case 401: // Code 401 can be obtain because credentials are wrong or the user's password has been compromised // To differentiate both responses, we check the response's body - if (cause != null && !Objects.equals(cause.getMessage(), INVALID_LOGIN_BODY)) { + if (cause != null && Objects.equals(cause.getMessage(), COMPROMISED_PASSWORD_BODY)) { return new AuthException(FailureType.COMPROMISED_PASSWORD, COMPROMISED_PASSWORD_MESSAGE, cause); } default: