@@ -453,6 +453,10 @@ else if(emailHash != null) {
453
453
input = InputUtil .normalizePhoneHash (phoneHash );
454
454
}
455
455
456
+ if (!checkForInvalidTokenInput (input , rc )) {
457
+ return ;
458
+ }
459
+
456
460
PrivacyBits privacyBits = new PrivacyBits ();
457
461
privacyBits .setLegacyBit ();
458
462
privacyBits .setClientSideTokenGenerate ();
@@ -893,7 +897,7 @@ private void handleTokenRefreshV2(RoutingContext rc) {
893
897
private void handleTokenValidateV1 (RoutingContext rc ) {
894
898
try {
895
899
final InputUtil .InputVal input = this .phoneSupport ? getTokenInputV1 (rc ) : getTokenInput (rc );
896
- if (this . phoneSupport ? ! checkTokenInputV1 ( input , rc ) : ! checkTokenInput (input , rc )) {
900
+ if (! checkForInvalidTokenInput (input , rc )) {
897
901
return ;
898
902
}
899
903
if ((Arrays .equals (ValidateIdentityForEmailHash , input .getIdentityInput ()) && input .getIdentityType () == IdentityType .Email )
@@ -924,7 +928,7 @@ private void handleTokenValidateV2(RoutingContext rc) {
924
928
final JsonObject req = (JsonObject ) rc .data ().get ("request" );
925
929
926
930
final InputUtil .InputVal input = getTokenInputV2 (req );
927
- if (this . phoneSupport ? ! checkTokenInputV1 ( input , rc ) : ! checkTokenInput (input , rc )) {
931
+ if (! checkForInvalidTokenInput (input , rc )) {
928
932
return ;
929
933
}
930
934
if ((input .getIdentityType () == IdentityType .Email && Arrays .equals (ValidateIdentityForEmailHash , input .getIdentityInput ()))
@@ -956,7 +960,7 @@ private void handleTokenGenerateV1(RoutingContext rc) {
956
960
try {
957
961
final InputUtil .InputVal input = this .phoneSupport ? this .getTokenInputV1 (rc ) : this .getTokenInput (rc );
958
962
platformType = getPlatformType (rc );
959
- if (this . phoneSupport ? ! checkTokenInputV1 ( input , rc ) : ! checkTokenInput (input , rc )) {
963
+ if (! checkForInvalidTokenInput (input , rc )) {
960
964
return ;
961
965
} else {
962
966
final IdentityTokens t = this .idService .generateIdentity (
@@ -983,7 +987,7 @@ private void handleTokenGenerateV2(RoutingContext rc) {
983
987
platformType = getPlatformType (rc );
984
988
985
989
final InputUtil .InputVal input = this .getTokenInputV2 (req );
986
- if (this . phoneSupport ? ! checkTokenInputV1 ( input , rc ) : ! checkTokenInput (input , rc )) {
990
+ if (! checkForInvalidTokenInput (input , rc )) {
987
991
return ;
988
992
} else {
989
993
final String apiContact = getApiContact (rc );
@@ -1258,7 +1262,7 @@ private void handleBucketsV2(RoutingContext rc) {
1258
1262
1259
1263
private void handleIdentityMapV1 (RoutingContext rc ) {
1260
1264
final InputUtil .InputVal input = this .phoneSupport ? this .getTokenInputV1 (rc ) : this .getTokenInput (rc );
1261
- if (this . phoneSupport ? ! checkTokenInputV1 ( input , rc ) : ! checkTokenInput (input , rc )) {
1265
+ if (! checkForInvalidTokenInput (input , rc )) {
1262
1266
return ;
1263
1267
}
1264
1268
try {
@@ -1387,20 +1391,10 @@ private InputUtil.InputVal getTokenInputV1(RoutingContext rc) {
1387
1391
return null ;
1388
1392
}
1389
1393
1390
- private boolean checkTokenInput (InputUtil .InputVal input , RoutingContext rc ) {
1391
- if (input == null ) {
1392
- ResponseUtil .ClientError (rc , "Required Parameter Missing: exactly one of email or email_hash must be specified" );
1393
- return false ;
1394
- } else if (!input .isValid ()) {
1395
- ResponseUtil .ClientError (rc , "Invalid Identifier" );
1396
- return false ;
1397
- }
1398
- return true ;
1399
- }
1400
-
1401
- private boolean checkTokenInputV1 (InputUtil .InputVal input , RoutingContext rc ) {
1394
+ private boolean checkForInvalidTokenInput (InputUtil .InputVal input , RoutingContext rc ) {
1402
1395
if (input == null ) {
1403
- ResponseUtil .ClientError (rc , "Required Parameter Missing: exactly one of [email, email_hash, phone, phone_hash] must be specified" );
1396
+ String message = this .phoneSupport ? "Required Parameter Missing: exactly one of [email, email_hash, phone, phone_hash] must be specified" : "Required Parameter Missing: exactly one of email or email_hash must be specified" ;
1397
+ ResponseUtil .ClientError (rc , message );
1404
1398
return false ;
1405
1399
} else if (!input .isValid ()) {
1406
1400
ResponseUtil .ClientError (rc , "Invalid Identifier" );
0 commit comments