fix(cognito): mark verified contact attribute on ConfirmSignUp (#1881)

* fix(cognito): mark verified contact attribute on ConfirmSignUp

* fix(cognito): add null guard for resolveSignUpDeliveryTarget in confirmSignUp

* fix(cognito): update ConfirmSignUp test assertions for phone first delivery
This commit is contained in:
Maciej authored and GitHub committed 2026-08-15 18:19:18 -05:00
1 parent 6c4d63b0a9
commit d891425943
3 files changed
+517 -11

No files matched your search

@@ -12,7 +12,14 @@ import io.github.hectorvent.floci.core.common.RegionResolver;
import io.github.hectorvent.floci.core.common.ReservedTags;
import io.github.hectorvent.floci.core.storage.StorageBackend;
import io.github.hectorvent.floci.core.storage.StorageFactory;
import io.github.hectorvent.floci.services.cognito.model.*;
import io.github.hectorvent.floci.services.cognito.model.CognitoGroup;
import io.github.hectorvent.floci.services.cognito.model.CognitoUser;
import io.github.hectorvent.floci.services.cognito.model.ResourceServer;
import io.github.hectorvent.floci.services.cognito.model.ResourceServerScope;
import io.github.hectorvent.floci.services.cognito.model.RevokedTokenInfo;
import io.github.hectorvent.floci.services.cognito.model.UserPool;
import io.github.hectorvent.floci.services.cognito.model.UserPoolClient;
import io.github.hectorvent.floci.services.cognito.model.UserPoolClientSecret;
import io.github.hectorvent.floci.services.cognito.verification.CognitoMessageDispatcher;
import io.github.hectorvent.floci.services.cognito.verification.VerificationCode;
import io.github.hectorvent.floci.services.cognito.verification.VerificationCodeException;
@@ -28,13 +35,32 @@ import org.jspecify.annotations.Nullable;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.nio.charset.StandardCharsets;
import java.security.*;
import java.security.KeyFactory;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.MessageDigest;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.Signature;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.time.Clock;
import java.time.Duration;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Base64;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import static io.github.hectorvent.floci.core.common.ReservedTags.rejectUnknownReservedTags;
@@ -1322,6 +1348,16 @@ public class CognitoService {
} catch (VerificationCodeException e) {
throw mapVerificationCodeException(e);
}
var signupDeliveryTarget = resolveSignUpDeliveryTarget(pool, user);
if (signupDeliveryTarget != null) {
if ("email".equals(signupDeliveryTarget.attributeName())) {
user.getAttributes().put("email_verified", "true");
} else if ("phone_number".equals(signupDeliveryTarget.attributeName())) {
user.getAttributes().put("phone_number_verified", "true");
}
}
}
user.setUserStatus("CONFIRMED");
user.setLastModifiedDate(System.currentTimeMillis() / 1000L);