From 99b8f26f2a97d2aad3b6d2d3d02357b9cc9c494d Mon Sep 17 00:00:00 2001 From: Yongjin Chong Date: Wed, 15 Jan 2025 21:34:39 -0700 Subject: [PATCH] Update TWO_FACTOR_METHOD_EMAIL from bottle --- lib/bullhorn/emails/user_emails.ex | 14 ++++++++++---- mix.exs | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/bullhorn/emails/user_emails.ex b/lib/bullhorn/emails/user_emails.ex index c006c77..044c68d 100644 --- a/lib/bullhorn/emails/user_emails.ex +++ b/lib/bullhorn/emails/user_emails.ex @@ -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("no-reply@system76.com") - |> 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 diff --git a/mix.exs b/mix.exs index 84fdc35..95a40be 100644 --- a/mix.exs +++ b/mix.exs @@ -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"},