From b7327d2c3475c5741b97274970f771851719d62d Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Mon, 4 Nov 2019 14:47:00 +0530 Subject: [PATCH] UX: show user email address on "grant admin access" email and UI --- app/jobs/regular/admin_confirmation_email.rb | 4 +++- app/mailers/admin_confirmation_mailer.rb | 3 ++- app/views/users/confirm_admin.html.erb | 2 +- config/locales/server.en.yml | 4 ++-- lib/admin_confirmation.rb | 1 + 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/jobs/regular/admin_confirmation_email.rb b/app/jobs/regular/admin_confirmation_email.rb index 23fd5b3d06a..48746de4084 100644 --- a/app/jobs/regular/admin_confirmation_email.rb +++ b/app/jobs/regular/admin_confirmation_email.rb @@ -7,13 +7,15 @@ module Jobs def execute(args) to_address = args[:to_address] token = args[:token] + target_email = args[:target_email] target_username = args[:target_username] raise Discourse::InvalidParameters.new(:to_address) if to_address.blank? raise Discourse::InvalidParameters.new(:token) if token.blank? + raise Discourse::InvalidParameters.new(:target_email) if target_email.blank? raise Discourse::InvalidParameters.new(:target_username) if target_username.blank? - message = AdminConfirmationMailer.send_email(to_address, target_username, token) + message = AdminConfirmationMailer.send_email(to_address, target_email, target_username, token) Email::Sender.new(message, :admin_confirmation_message).send end diff --git a/app/mailers/admin_confirmation_mailer.rb b/app/mailers/admin_confirmation_mailer.rb index e7ff1cde99c..9b6ffa2409c 100644 --- a/app/mailers/admin_confirmation_mailer.rb +++ b/app/mailers/admin_confirmation_mailer.rb @@ -3,10 +3,11 @@ class AdminConfirmationMailer < ActionMailer::Base include Email::BuildEmailHelper - def send_email(to_address, target_username, token) + def send_email(to_address, target_email, target_username, token) build_email( to_address, template: 'admin_confirmation_mailer', + target_email: target_email, target_username: target_username, admin_confirm_url: confirm_admin_url(token: token, host: Discourse.base_url) ) diff --git a/app/views/users/confirm_admin.html.erb b/app/views/users/confirm_admin.html.erb index 2f9d3cdd4a7..e9a1dbbea14 100644 --- a/app/views/users/confirm_admin.html.erb +++ b/app/views/users/confirm_admin.html.erb @@ -3,7 +3,7 @@
<%- unless @confirmed %> - <%=raw (t('activation.admin_confirm.description', target_username: @confirmation.target_user.username)) %> + <%=raw (t('activation.admin_confirm.description', target_email: @confirmation.target_user.email, target_username: @confirmation.target_user.username)) %>

diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index bc323fbb774..bdebcbbdd54 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -822,7 +822,7 @@ en: activated: "Sorry, this account has already been activated." admin_confirm: title: "Confirm Admin Account" - description: "Are you sure you want %{target_username} to be an administrator?" + description: "Are you sure you want %{target_username} (%{target_email}) to be an administrator?" grant: "Grant Admin Access" complete: "%{target_username} is now an administrator." back_to: "Return to %{title}" @@ -2477,7 +2477,7 @@ en: title: "Admin Confirmation" subject_template: "[%{email_prefix}] Confirm new Admin Account" text_body_template: | - Please confirm that you'd like to add **%{target_username}** as an administrator for your forum. + Please confirm that you'd like to add **%{target_username} (%{target_email})** as an administrator for your forum. [Confirm Administrator Account](%{admin_confirm_url}) diff --git a/lib/admin_confirmation.rb b/lib/admin_confirmation.rb index d21b8aaac95..bf9254db431 100644 --- a/lib/admin_confirmation.rb +++ b/lib/admin_confirmation.rb @@ -26,6 +26,7 @@ class AdminConfirmation Jobs.enqueue( :admin_confirmation_email, to_address: @performed_by.email, + target_email: @target_user.email, target_username: @target_user.username, token: @token )