Skip to content

Refactor the dormant user deactivation worker to use deactivate service

sameer shaik requested to merge audit-dormant into master

What does this MR do and why?

This Merge Request (MR) addresses the issue detailed here: #418904 (closed).

Previously in !117776 (merged), a new service was introduced to manage the deactivation of users, consolidating all manual deactivation actions into a single service. However, we also have a feature that automatically deactivates dormant users. This feature's worker was still utilizing the .deactivate method, resulting in a lack of audit event logging, as this functionality wasn't handled by the new deactivation service.

In this MR, we modify the worker to use the new deactivation service. This change ensures consistency in our codebase and that automatic user deactivation actions are logged in the audit events, improving visibility.

Screenshots or screen recordings

Before: Audit events are not logged for dormant user deactivation worker.

After:

Screenshot_2023-07-20_at_10.56.37_AM

How to set up and validate locally

  1. Checkout the feature branch audit-dormant. Make sure to have a user that is dormant on your GitLab instance. Use the following to mark some users as dormant:
 user=User.find(17)
 user.update!(last_activity_on: 400.days.ago)
 user.update!(current_sign_in_at: 400.days.ago)
  1. Enable Automatic deactivation of dormant users.
  2. Run Users::DeactivateDormantUsersWorker.new.perform worker through Rails console.
  3. The dormant user should get deactivated and the audit event will be logged in the instance level audit

MR acceptance checklist

This checklist encourages us to confirm any changes have been analysed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by sameer shaik

Merge request reports