mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
fix(cognito): clear stale pending admin updates (#2533)
This commit is contained in:
1 parent
5ae3ed8976
commit
a704f731aa
2 files changed
+119
No files matched your search
@@ -1791,6 +1791,8 @@ public class CognitoService implements ResourceProvider {
|
||||
}
|
||||
}
|
||||
}
|
||||
attributes.keySet().forEach(attributeName ->
|
||||
clearPendingAttributeVerification(userPoolId, user, attributeName));
|
||||
user.getAttributes().putAll(attributes);
|
||||
user.setLastModifiedDate(System.currentTimeMillis() / 1000L);
|
||||
userStore.put(userKey(userPoolId, user.getUsername()), user);
|
||||
@@ -1800,6 +1802,7 @@ public class CognitoService implements ResourceProvider {
|
||||
CognitoUser user = adminGetUser(userPoolId, username);
|
||||
for (String attrName : attributeNames) {
|
||||
user.getAttributes().remove(attrName);
|
||||
clearPendingAttributeVerification(userPoolId, user, attrName);
|
||||
}
|
||||
user.setLastModifiedDate(System.currentTimeMillis() / 1000L);
|
||||
userStore.put(userKey(userPoolId, user.getUsername()), user);
|
||||
@@ -4026,6 +4029,18 @@ public class CognitoService implements ResourceProvider {
|
||||
return "email".equals(attributeName) || "phone_number".equals(attributeName);
|
||||
}
|
||||
|
||||
private void clearPendingAttributeVerification(String userPoolId, CognitoUser user,
|
||||
String attributeName) {
|
||||
if (!isVerifiableContactAttribute(attributeName)) {
|
||||
return;
|
||||
}
|
||||
user.getPendingAttributes().remove(attributeName);
|
||||
if (verificationCodeService != null) {
|
||||
verificationCodeService.invalidatePrevious(
|
||||
userPoolId, user.getUsername(), verificationPurpose(attributeName));
|
||||
}
|
||||
}
|
||||
|
||||
private VerificationCode.Purpose verificationPurpose(String attributeName) {
|
||||
return "email".equals(attributeName)
|
||||
? VerificationCode.Purpose.EMAIL_ATTRIBUTE_VERIFICATION
|
||||
|
||||
Reference in new issue
Block a user