Refactor the dormant user deactivation worker to use deactivate service
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:
How to set up and validate locally
- 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)
- Enable Automatic deactivation of dormant users.
- Run
Users::DeactivateDormantUsersWorker.new.perform
worker through Rails console. - 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.
-
I have evaluated the MR acceptance checklist for this MR.