Skip to content

Commit

Permalink
Update TWO_FACTOR_METHOD_EMAIL from bottle
Browse files Browse the repository at this point in the history
  • Loading branch information
zephyranthes03 committed Jan 16, 2025
1 parent 4a8ea4c commit 99b8f26
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions lib/bullhorn/emails/user_emails.ex
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,26 @@ defmodule Bullhorn.Emails.UserEmails do
|> MailgunHelper.substitute_variables("first_name", first_name)
end

def deliver_email_two_factor_token(%{email: email, first_name: first_name} = user, token) do
def deliver_email_two_factor_token(%{email: email} = user, token) do
spaced_out_token =
token
|> String.upcase()
|> String.split("")
|> Enum.join(". ")

fields_for_email = [:email, :first_name, :last_name]

user_variables =
user
|> Map.take(fields_for_email)
|> Map.put(:two_factor_token, spaced_out_token)

new_email()
|> to({full_name(user), email})
|> from("[email protected]")
|> subject("Your System76 verification code")
|> subject("Your System76 login verification code")
|> MailgunHelper.template("deliver_email_two_factor_token")
|> MailgunHelper.substitute_variables("first_name", first_name)
|> MailgunHelper.substitute_variables("two_factor_token", spaced_out_token)
|> MailgunHelper.substitute_variables("user", user_variables)
end


Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ defmodule Bullhorn.MixProject do
{:appsignal, "~> 1.0"},
{:amqp, "~> 2.0", override: true},
{:bamboo, "~> 1.6"},
{:bottle, github: "system76/bottle", ref: "bd102de771893e0135e566926e8f571578b5177b"},
{:bottle, github: "system76/bottle", ref: "1a49e7bc7d8f7bf556c5780b70e9eb60a06a8ca7"},
{:broadway_rabbitmq, "~> 0.7.2"},
{:credo, "~> 1.3", only: [:dev, :test]},
{:decorator, "~> 1.2"},
Expand Down

0 comments on commit 99b8f26

Please sign in to comment.