Skip to content

Commit 0f428ed

Browse files
committed
Add origin to account creation api
1 parent 2a480e6 commit 0f428ed

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

app/controllers/api/v8/users_controller.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ def create
8383
set_extra_data
8484

8585
if @user.errors.empty? && @user.save
86-
UserMailer.email_confirmation(@user).deliver_now
86+
# TODO: Whitelist origins
87+
UserMailer.email_confirmation(@user, params[:origin]).deliver_now
8788
render json: {
8889
success: true,
8990
message: 'User created.'

app/mailers/user_mailer.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
class UserMailer < ActionMailer::Base
2-
def email_confirmation(user)
2+
def email_confirmation(user, origin = nil)
3+
@origin = origin
34
@user = user
45
token = user.verification_tokens.email.create!
56
@url = base_url + confirm_email_path(@user.id, token.token)

app/views/user_mailer/email_confirmation.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<body>
77
<p>Hey there!</p>
88

9-
<p>Please click the following link to confirm that this is your email address for the mooc.fi account "<%= @user.login %>".</p>
9+
<p>Please click the following link to confirm that this is your email address for the mooc.fi account <%= @user.login %>.<%= @origin ? " The account was created from '#{@origin}'." : '' %> </p>
1010

1111
<a href="<%= @url %>"><%= @url %></a>
1212

app/views/user_mailer/email_confirmation.text.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Hey there!
22

3-
Please click the following link to confirm that this is your email address for the mooc.fi account "<%= @user.login %>"
3+
Please click the following link to confirm that this is your email address for the mooc.fi account <%= @user.login %>. <%= @origin ? " The account was created from '#{@origin}'." : '' %>
44

55
<%= @url %>
66

0 commit comments

Comments
 (0)