respond_to do |format|
if current_user.andand.is_admin
setup_params = {}
+ setup_params[:send_notification_email] = "#{Rails.configuration.send_user_setup_notification_email}"
if params['user_uuid'] && params['user_uuid'].size>0
setup_params[:uuid] = params['user_uuid']
end
show_user_agreement_inline: false
secret_token: ~
default_openid_prefix: https://www.google.com/accounts/o8/id
+ send_user_setup_notification_email: true
params[:repo_name], params[:vm_uuid]
end
+ # setup succeeded. send email to user
+ if params[:send_notification_email] == true || params[:send_notification_email] == 'true'
+ UserNotifier.account_is_setup(@object).deliver
+ end
+
render json: { kind: "arvados#HashList", items: @response }
end
show
end
+ protected
+
+ def self._setup_requires_parameters
+ {
+ send_notification_email: { type: 'boolean', required: true },
+ }
+ end
+
end
--- /dev/null
+class UserNotifier < ActionMailer::Base
+ default from: Rails.configuration.user_notifier_email_from
+
+ def account_is_setup(user)
+ @user = user
+ mail(to: user.email, subject: 'Welcome to Curoverse')
+ end
+end
--- /dev/null
+<%= @user.full_name %>,
+
+Your Arvados account has been set up. You can log in here using your
+Google account (<%= @user.email %>):
+
+<%= Rails.configuration.workbench_address %>
new_users_are_active: false
admin_notifier_email_from: arvados@example.com
email_subject_prefix: "[ARVADOS] "
+ user_notifier_email_from: arvados@example.com
# Visitors to the API server will be redirected to the workbench
workbench_address: https://workbench.local:3001/
with this OpenID prefix *and* a matching email address in order to \
claim the account.
eos
+ opt :send_notification_email, <<-eos, default: 'true'
+Send notification email after successfully setting up the user.
+ eos
end
log.level = (ENV['DEBUG'] || opts.debug) ? Logger::DEBUG : Logger::WARN
# Invoke user setup method
if (found_user)
user = arv.user.setup uuid: found_user[:uuid], repo_name: user_repo_name,
- vm_uuid: vm_uuid, openid_prefix: opts.openid_prefix
+ vm_uuid: vm_uuid, openid_prefix: opts.openid_prefix,
+ send_notification_email: opts.send_notification_email
else
user = arv.user.setup user: {email: user_arg}, repo_name: user_repo_name,
- vm_uuid: vm_uuid, openid_prefix: opts.openid_prefix
+ vm_uuid: vm_uuid, openid_prefix: opts.openid_prefix,
+ send_notification_email: opts.send_notification_email
end
log.info {"user uuid: " + user[:uuid]}
--- /dev/null
+require 'test_helper'
+
+class UserNotifierTest < ActionMailer::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end