Skip to content

Notify users that they haven't login in a while and deactivate accounts#596

Open
santostiago wants to merge 2 commits into
developfrom
job/automatically-deactivate-old-accounts
Open

Notify users that they haven't login in a while and deactivate accounts#596
santostiago wants to merge 2 commits into
developfrom
job/automatically-deactivate-old-accounts

Conversation

@santostiago
Copy link
Copy Markdown
Contributor

Pull request checklist

Please check if your PR fulfills the following requirements:

  • Make sure you are requesting to pull a topic/feature/bugfix branch (right side). Don't request your master!
  • Make sure you are making a pull request against the develop branch (left side). Also you should start your branch off our develop.
  • Check the commit's or even all commits' message styles matches our requested structure.
  • Check your code additions will fail neither code linting checks nor unit test.

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

Issue Number: https://gfw.atlassian.net/browse/OPEN-376

What is the new behavior?

We run a job every day that warns users that haven't logged in in a while that their accounts will be disabled.
Disable users that have not logged in in 2 years.

Does this introduce a breaking change?

  • Yes
  • No

Other information

@santostiago santostiago force-pushed the job/automatically-deactivate-old-accounts branch from 4ddd988 to 9dbff88 Compare May 1, 2026 12:17
@santostiago santostiago marked this pull request as ready for review May 1, 2026 12:17
@santostiago santostiago requested a review from tsubik May 1, 2026 12:17
@santostiago santostiago self-assigned this May 1, 2026
Copy link
Copy Markdown
Collaborator

@tsubik tsubik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing should be changed, webuser cannot be deactivated. Other than that, looks really good.

subject(:run_task) { Rake::Task["scheduler:deactivate_inactive_users"].invoke }

around do |example|
travel_to(Time.zone.parse("2026-04-30 10:00:00")) { example.run }
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to set fixed time here for every example?

account_deactivated_for_inactivity:
subject: "Your Open Timber Portal account has been deactivated"
message: "Because your account has not been used for 2 years, it is now deactivated."
contact: "If you need help or think this is an error, please contact the OTP team."
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we put CONTACT_EMAIL here as well? I think question to Sophie.

Comment thread lib/tasks/scheduler.rake
deactivated_users = 0

time = Benchmark.ms do
warning_users = User.where(is_active: true)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should filter out special user webuser@example.com, that user cannot be deactivated.

Comment thread lib/tasks/scheduler.rake
warned_users += 1
end

users_to_deactivate = User.where(is_active: true)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder should we at least warn user once? Or just go straight to deactivate. The problem is only for the first run. I see a lot of users will be deactivated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants