diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
commit | 6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch) | |
tree | 78be5963ec075d80116a932011d695dd33910b4e /app/workers/personal_access_tokens/expired_notification_worker.rb | |
parent | 1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff) |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'app/workers/personal_access_tokens/expired_notification_worker.rb')
-rw-r--r-- | app/workers/personal_access_tokens/expired_notification_worker.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/app/workers/personal_access_tokens/expired_notification_worker.rb b/app/workers/personal_access_tokens/expired_notification_worker.rb new file mode 100644 index 00000000000..c1b1f1a461d --- /dev/null +++ b/app/workers/personal_access_tokens/expired_notification_worker.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +module PersonalAccessTokens + class ExpiredNotificationWorker # rubocop:disable Scalability/IdempotentWorker + include ApplicationWorker + include CronjobQueue + + feature_category :authentication_and_authorization + + def perform(*args) + return unless Feature.enabled?(:expired_pat_email_notification) + + notification_service = NotificationService.new + + User.with_personal_access_tokens_expired_today.find_each do |user| + with_context(user: user) do + Gitlab::AppLogger.info "#{self.class}: Notifying User #{user.id} about an expired token" + + notification_service.access_token_expired(user) + + user.personal_access_tokens.without_impersonation.expired_today_and_not_notified.update_all(after_expiry_notification_delivered: true) + end + end + end + end +end |