2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-08-20 11:36:14 -04:00
|
|
|
module Jobs
|
|
|
|
|
2019-10-02 00:01:53 -04:00
|
|
|
class AutoExpireUserApiKeys < ::Jobs::Scheduled
|
2018-08-20 11:36:14 -04:00
|
|
|
every 1.day
|
|
|
|
|
|
|
|
def execute(args)
|
|
|
|
if SiteSetting.expire_user_api_keys_days > 0
|
|
|
|
expire_user_api_keys_days = SiteSetting.expire_user_api_keys_days.days.ago
|
|
|
|
|
|
|
|
UserApiKey.where("last_used_at < ?", expire_user_api_keys_days).update_all(revoked_at: Time.zone.now)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|