Add optional notification for new users that are in the inactive state.
authorWard Vandewege <ward@curoverse.com>
Wed, 23 Apr 2014 15:12:05 +0000 (11:12 -0400)
committerWard Vandewege <ward@curoverse.com>
Tue, 6 May 2014 15:10:13 +0000 (11:10 -0400)
services/api/app/mailers/admin_notifier.rb
services/api/app/models/user.rb
services/api/app/views/admin_notifier/new_inactive_user.text.erb [new file with mode: 0644]
services/api/config/application.default.yml

index 5de70053dcf0265258244ad252df341936334154..d291e86f9a746890c6fdfe5d4b0fea7c5cc03dbf 100644 (file)
@@ -5,6 +5,13 @@ class AdminNotifier < ActionMailer::Base
     self.generic_callback('after_create', model, *args)
   end
 
     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)
   protected
 
   def generic_callback(callback_type, model, *args)
index 81cae987a20d023f61d96a0ade93c9dd75d60c84..b6b7e67ff17b493b648f525b3d17fe5887950dc6 100644 (file)
@@ -8,6 +8,7 @@ class User < ArvadosModel
   before_update :prevent_inactive_admin
   before_create :check_auto_admin
   after_create :add_system_group_permission_link
   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
   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
                   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
 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 (file)
index 0000000..98c7037
--- /dev/null
@@ -0,0 +1,7 @@
+
+A new user landed on the inactive user page:
+
+  <%= @user.full_name %> <<%= @user.email %>>
+
+Thanks,
+Your friendly Arvados robot.
index 37bb1c380f9d48091c76ec167093c7b532709124..9966b95591ffe01595a41bb1c01e738a142e03c4 100644 (file)
@@ -86,6 +86,7 @@ common:
   admin_notifier_email_from: arvados@example.com
   email_subject_prefix: "[ARVADOS] "
   user_notifier_email_from: arvados@example.com
   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/
 
   # Visitors to the API server will be redirected to the workbench
   workbench_address: https://workbench.local:3001/