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