Handle special cases when mass unconfirming users
requested to merge 232534-skip-running-unconfirm-migration-when-email-confirmation-is-off into master
What does this MR do?
This MR changes the existing mass unconfirm user migration to handle two special cases where unconfirmation is not needed:
- Skip unconfirmation completely if the
send_user_confirmation_email
setting is off. - Skip unconfirmation for a particular user when the email attribute is synced via LDAP.
The underlying query was extended with an NOT EXISTS
subquery, it doesn't add too much overhead since the batch size is small.
SELECT "emails".* FROM "emails"
INNER JOIN "users" ON "users"."id" = "emails"."user_id"
WHERE
"users"."state" = 'active' AND
"users"."user_type" IS NULL AND
"emails"."id" BETWEEN 425000 AND 426000
AND (emails.confirmed_at IS NOT NULL)
AND (emails.confirmed_at = users.confirmed_at)
AND (emails.email <> users.email)
AND NOT EXISTS (SELECT 1 FROM user_synced_attributes_metadata WHERE user_id=users.id AND email_synced IS true)
Plan: https://explain.depesz.com/s/P7p4 (no LDAP users on GL.com)
Note: the migration was already executed on GL.com
Does this MR meet the acceptance criteria?
Conformity
- [-] Changelog entry
- [-] Documentation (if required)
-
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides - [-] Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. - [-] Tested in all supported browsers
- [-] Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
- [-] Label as security and @ mention
@gitlab-com/gl-security/appsec
- [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
- [-] Security reports checked/validated by a reviewer from the AppSec team
Related to #232534 (closed)
Edited by Mayra Cabrera