Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-10 10:53:40 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-10 10:53:40 +0300
commitcfc792b9ca064990e6540cb742e80529ea669a81 (patch)
tree147cd4256319990cebbc02fe8e4fbbbe06f5720a /app/workers/personal_access_tokens
parent93c6764dacd4c605027ef1cd367d3aebe420b223 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/workers/personal_access_tokens')
-rw-r--r--app/workers/personal_access_tokens/expiring_worker.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/app/workers/personal_access_tokens/expiring_worker.rb b/app/workers/personal_access_tokens/expiring_worker.rb
new file mode 100644
index 00000000000..f28109c4583
--- /dev/null
+++ b/app/workers/personal_access_tokens/expiring_worker.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+module PersonalAccessTokens
+ class ExpiringWorker
+ include ApplicationWorker
+ include CronjobQueue
+
+ feature_category :authentication_and_authorization
+
+ def perform(*args)
+ notification_service = NotificationService.new
+ limit_date = PersonalAccessToken::DAYS_TO_EXPIRE.days.from_now.to_date
+
+ User.with_expiring_and_not_notified_personal_access_tokens(limit_date).find_each do |user|
+ notification_service.access_token_about_to_expire(user)
+
+ Rails.logger.info "#{self.class}: Notifying User #{user.id} about expiring tokens" # rubocop:disable Gitlab/RailsLogger
+
+ user.personal_access_tokens.expiring_and_not_notified(limit_date).update_all(expire_notification_delivered: true)
+ end
+ end
+ end
+end