Added valid until text to invite email (#2599)

This commit is contained in:
Ahmad Farhat 2021-03-22 19:26:51 -04:00 committed by GitHub
parent c21dd8f39a
commit 79beb7f3fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 17 additions and 9 deletions

View File

@ -145,7 +145,7 @@ class AdminsController < ApplicationController
emails.each do |email|
invitation = create_or_update_invite(email)
send_invitation_email(current_user.name, email, invitation.invite_token)
send_invitation_email(current_user.name, email, invitation)
end
redirect_back fallback_location: admins_path

View File

@ -70,11 +70,11 @@ module Emailer
end
# Sends inivitation to join
def send_invitation_email(name, email, token)
def send_invitation_email(name, email, invite)
begin
return unless Rails.configuration.enable_email_verification
UserMailer.invite_email(name, email, invitation_link(token), @settings).deliver_now
UserMailer.invite_email(name, email, invite.updated_at, invitation_link(invite.invite_token), @settings).deliver_now
rescue => e
logger.error "Support: Error in email delivery: #{e}"
flash[:alert] = I18n.t(params[:message], default: I18n.t("delivery_error"))

View File

@ -88,7 +88,10 @@ class SessionsController < ApplicationController
# Check that the user is a Greenlight account
return redirect_to(root_path, alert: I18n.t("invalid_login_method")) unless user.greenlight_account?
# Check that the user has verified their account
return redirect_to(account_activation_path(digest: user.activation_digest)) unless user.activated?
unless user.activated?
user.create_activation_token
return redirect_to(account_activation_path(digest: user.activation_digest))
end
end
login(user)

View File

@ -64,13 +64,14 @@ class UserMailer < ApplicationMailer
mail to: user.email, subject: t('mailer.user.demoted.subtitle', role: translated_role_name(role))
end
def invite_email(name, email, url, settings)
def invite_email(name, email, invite_date, url, settings)
@settings = settings
@name = name
@email = email
@url = url
@image = logo_image
@color = user_color
@date = "#{(invite_date + 2.days).strftime('%b %d, %Y %-I:%M%P')} UTC"
mail to: email, subject: t('mailer.user.invite.subject')
end

View File

@ -32,10 +32,14 @@
<%= t('mailer.user.invite.username', email: @email) %>
</p>
<p style="margin-bottom:35px;">
<p>
<%= t('mailer.user.invite.signup_info') %>
</p>
<p style="margin-bottom:35px;">
<%= t('mailer.user.invite.valid', date: @date) %>
</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="<%= @url %>">
<%= t('mailer.user.invite.signup_link') %>
</a>

View File

@ -356,6 +356,7 @@ en:
info: You have been invited to your own personal space by %{name}
signup_info: To signup using your email, click the button below and follow the steps.
signup_link: Sign Up
valid: "The invite is valid until: %{date}"
signup:
info: A user that was invited has signed up to use Greenlight.
admins_link: Visit the Organization Page

View File

@ -3,8 +3,7 @@
class UserMailerPreview < ActionMailer::Preview
def initialize(_params)
super
@logo = "https://raw.githubusercontent.com/bigbluebutton/greenlight/master/app/assets/images/logo_with_text.png"
@color = "#467fcf"
@settings = Setting.find_by(provider: "greenlight")
end
# Preview this email at
@ -27,7 +26,7 @@ class UserMailerPreview < ActionMailer::Preview
# Preview this email at
# http://localhost:3000/rails/mailers/user_mailer/invite_email
def invite_email
UserMailer.invite_email("Example User", "from@example.com", "http://example.com/signup", @logo, @color)
UserMailer.invite_email("Example User", "from@example.com", DateTime.now, "http://example.com/signup", @settings)
end
# Preview this email at