Skip to content

Commit 4a28d73

Browse files
committed
Elements of AI email confirmation redirect
1 parent ee636aa commit 4a28d73

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

app/controllers/users_controller.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,10 @@ def update
8080

8181
def confirm_email
8282
token = VerificationToken.email.find_by!(user_id: params[:user_id], token: params[:id])
83+
redirect_path = root_url
84+
redirect_path = 'https://course.elementsofai.com' if params[:origin] == 'elements_of_ai'
8385
User.find(params[:user_id]).update!(email_verified: true)
84-
redirect_to root_url, notice: 'Your email address has been verified!'
86+
redirect_to redirect_path, notice: 'Your email address has been verified!'
8587
end
8688

8789
def send_verification_email

app/mailers/user_mailer.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require 'cgi'
2+
13
class UserMailer < ActionMailer::Base
24
def email_confirmation(user, origin = nil)
35
@origin = origin
@@ -6,6 +8,10 @@ def email_confirmation(user, origin = nil)
68
@url = base_url + confirm_email_path(@user.id, token.token)
79
subject = "Confirm your mooc.fi account email address"
810
subject = "#{origin}: #{subject}" if origin
11+
if origin
12+
origin_name = origin.downcase.tr(' ', '_').gsub(/[\.\/]/, '')
13+
@url = @url + "?origin=#{CGI.escape(origin_name)}"
14+
end
915
mail(from: SiteSetting.value('emails')['from'], to: user.email, subject: subject)
1016
end
1117

0 commit comments

Comments
 (0)