2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-12-12 15:32:14 -05:00
|
|
|
module Jobs
|
|
|
|
|
2019-10-02 00:01:53 -04:00
|
|
|
class InvalidateInactiveAdmins < ::Jobs::Scheduled
|
2018-12-12 15:32:14 -05:00
|
|
|
every 1.day
|
|
|
|
|
|
|
|
def execute(_)
|
|
|
|
return if SiteSetting.invalidate_inactive_admin_email_after_days == 0
|
|
|
|
|
|
|
|
User.human_users
|
|
|
|
.where(admin: true)
|
2018-12-12 22:59:56 -05:00
|
|
|
.where(active: true)
|
2018-12-12 15:32:14 -05:00
|
|
|
.where('last_seen_at < ?', SiteSetting.invalidate_inactive_admin_email_after_days.days.ago)
|
|
|
|
.each do |user|
|
|
|
|
|
2018-12-12 22:59:56 -05:00
|
|
|
User.transaction do
|
2019-04-03 12:04:05 -04:00
|
|
|
user.deactivate(Discourse.system_user)
|
2018-12-12 22:59:56 -05:00
|
|
|
user.email_tokens.update_all(confirmed: false, expired: true)
|
2018-12-12 15:32:14 -05:00
|
|
|
|
2018-12-12 22:59:56 -05:00
|
|
|
Discourse.authenticators.each do |authenticator|
|
|
|
|
if authenticator.can_revoke? && authenticator.description_for_user(user).present?
|
|
|
|
authenticator.revoke(user)
|
|
|
|
end
|
2018-12-12 15:32:14 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|