fix(cognito): prefer phone delivery for signup verification (#1839)

Signed-off-by: Vinod Kumar <codingkiddo@gmail.com>
This commit is contained in:
Vinod Kumar Bengaluru authored and GitHub committed 2026-07-28 21:25:52 -05:00
1 parent 8f3597c205
commit 2f435fd1c9
2 files changed
+57 -13

No files matched your search

@@ -2488,19 +2488,15 @@ public class CognitoService {
List<String> autoVerifiedAttributes =
pool.getAutoVerifiedAttributes() != null ? pool.getAutoVerifiedAttributes()
: List.of();
for (String attribute : autoVerifiedAttributes) {
if ("email".equals(attribute)) {
String email = blankToNull(attributes.get("email"));
if (email != null) {
return new DeliveryTarget("email", "EMAIL", maskEmail(email));
}
}
if ("phone_number".equals(attribute)) {
String phoneNumber = blankToNull(attributes.get("phone_number"));
if (phoneNumber != null) {
return new DeliveryTarget("phone_number", "SMS", maskPhoneNumber(phoneNumber));
}
}
String phoneNumber = blankToNull(attributes.get("phone_number"));
if (autoVerifiedAttributes.contains("phone_number") && phoneNumber != null) {
return new DeliveryTarget("phone_number", "SMS", maskPhoneNumber(phoneNumber));
}
String email = blankToNull(attributes.get("email"));
if (autoVerifiedAttributes.contains("email") && email != null) {
return new DeliveryTarget("email", "EMAIL", maskEmail(email));
}
return null;