Skip to content

Handle special cases when mass unconfirming users

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

Availability and Testing

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

Merge request reports