From: Ward Vandewege Date: Wed, 23 Apr 2014 15:12:05 +0000 (-0400) Subject: Add optional notification for new users that are in the inactive state. X-Git-Tag: 1.1.0~2575^2~17^2~13 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/83a8512fad199107ff54762658a55176d479a5bb?ds=inline Add optional notification for new users that are in the inactive state. --- diff --git a/services/api/app/mailers/admin_notifier.rb b/services/api/app/mailers/admin_notifier.rb index 5de70053dc..d291e86f9a 100644 --- a/services/api/app/mailers/admin_notifier.rb +++ b/services/api/app/mailers/admin_notifier.rb @@ -5,6 +5,13 @@ class AdminNotifier < ActionMailer::Base self.generic_callback('after_create', model, *args) end + def new_inactive_user(user) + @user = user + if not Rails.configuration.new_inactive_user_notification_recipients.empty? then + mail(to: Rails.configuration.new_inactive_user_notification_recipients, subject: 'New inactive user notification') + end + end + protected def generic_callback(callback_type, model, *args) diff --git a/services/api/app/models/user.rb b/services/api/app/models/user.rb index 81cae987a2..b6b7e67ff1 100644 --- a/services/api/app/models/user.rb +++ b/services/api/app/models/user.rb @@ -8,6 +8,7 @@ class User < ArvadosModel before_update :prevent_inactive_admin before_create :check_auto_admin after_create :add_system_group_permission_link + after_create :send_admin_notifications after_create AdminNotifier has_many :authorized_keys, :foreign_key => :authorized_user_uuid, :primary_key => :uuid @@ -394,4 +395,10 @@ class User < ArvadosModel head_uuid: self.uuid) end end + + def send_admin_notifications + if not self.is_active then + AdminNotifier.new_inactive_user(self).deliver + end + end end diff --git a/services/api/app/views/admin_notifier/new_inactive_user.text.erb b/services/api/app/views/admin_notifier/new_inactive_user.text.erb new file mode 100644 index 0000000000..98c70374be --- /dev/null +++ b/services/api/app/views/admin_notifier/new_inactive_user.text.erb @@ -0,0 +1,7 @@ + +A new user landed on the inactive user page: + + <%= @user.full_name %> <<%= @user.email %>> + +Thanks, +Your friendly Arvados robot. diff --git a/services/api/config/application.default.yml b/services/api/config/application.default.yml index 37bb1c380f..9966b95591 100644 --- a/services/api/config/application.default.yml +++ b/services/api/config/application.default.yml @@ -86,6 +86,7 @@ common: admin_notifier_email_from: arvados@example.com email_subject_prefix: "[ARVADOS] " user_notifier_email_from: arvados@example.com + new_inactive_user_notification_recipients: '' # Visitors to the API server will be redirected to the workbench workbench_address: https://workbench.local:3001/