emails: send welcome mail on signup.

This commit is contained in:
evazion
2020-03-14 19:18:28 -05:00
parent d860fab7f5
commit 0ef9d6e417
5 changed files with 34 additions and 0 deletions

View File

@@ -65,6 +65,7 @@ class UsersController < ApplicationController
@user.save
if @user.errors.empty?
session[:user_id] = @user.id
UserMailer.welcome_user(@user).deliver_later
else
flash[:notice] = "Sign up failed: #{@user.errors.full_messages.join("; ")}"
end

View File

@@ -16,4 +16,9 @@ class UserMailer < ApplicationMailer
@user = user
mail to: @user.email_with_name, subject: "Confirm your email address"
end
def welcome_user(user)
@user = user
mail to: @user.email_with_name, subject: "Welcome to #{Danbooru.config.app_name}! Confirm your email address"
end
end

View File

@@ -0,0 +1,19 @@
<!doctype html>
<html>
<body>
<h2>Hi <%= @user.name %>,</h2>
<p>
Welcome to <%= Danbooru.config.app_name %>! Click the link below to verify your email address.
</p>
<p>
<%= link_to "Verify email address", verify_user_email_url(@user, email_verification_key: Danbooru::MessageVerifier.new(:email_verification_key).generate(@user.email_address.id)) %>
</p>
<p>
By verifying your email address, you can receive site notifications and you can
recover your account if you ever forget your password.
</p>
</body>
</html>