fixes #2082 proper link in mail (#2083)

* fixes #2082 proper link in mail

only send the promoted user a link to the admin page if their role 
allows them to.

* addressed review

Co-authored-by: Ahmad Farhat <ahmad.af.farhat@gmail.com>
This commit is contained in:
Toni Förster 2020-09-15 22:08:32 +02:00 committed by GitHub
parent ca94ac46ba
commit a27884733d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 3 deletions

View File

@ -47,6 +47,10 @@ class UserMailer < ApplicationMailer
@image = logo_image
@color = user_color
@role = translated_role_name(role)
@admin_role = role.get_permission("can_manage_users") ||
role.get_permission("can_manage_rooms_recordings") ||
role.get_permission("can_edit_site_settings") ||
role.get_permission("can_edit_roles")
mail to: user.email, subject: t('mailer.user.promoted.subtitle', role: translated_role_name(role))
end

View File

@ -32,8 +32,8 @@
<%= t('mailer.user.promoted.more-info', url: @url) %>
</p>
<a style="background: <%= @color %>;color: #ffffff; padding: 10px 15px; box-shadow: 0 2px 4px 0 rgba(0,0,0,.25);border: 1px solid transparent;text-decoration:none;" href="<%= @admin_url %>">
<%= t('mailer.user.promoted.admins_link') %>
<a style="background: <%= @color %>;color: #ffffff; padding: 10px 15px; box-shadow: 0 2px 4px 0 rgba(0,0,0,.25);border: 1px solid transparent;text-decoration:none;" href="<%= @admin_role ? @admin_url : @url%>">
<%= @admin_role ? t('mailer.user.promoted.admins_link') : t('mailer.user.approve.signin_link')%>
</a>
</div>
</div>

View File

@ -23,4 +23,4 @@
<%= t('mailer.user.promoted.more-info', url: @url) %>
<%= @admin_url %>
<%= @admin_role ? @admin_url : @url %>