Skip to content

Commit b5e2017

Browse files
committed
remove with
1 parent 52e4d7c commit b5e2017

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

lib/ret_web/email.ex

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,21 @@ defmodule RetWeb.Email do
66
app_name = AppConfig.get_cached_config_value("translations|en|app-name")
77
app_full_name = AppConfig.get_cached_config_value("translations|en|app-full-name") || app_name
88
admin_email = Application.get_env(:ret, Ret.Account)[:admin_email]
9+
custom_login_subject = AppConfig.get_cached_config_value("auth|login_subject")
10+
custom_login_body = AppConfig.get_cached_config_value("auth|login_body")
911

1012
email_subject =
11-
with custom_login_subject <-
12-
AppConfig.get_config_value("auth|login_subject"),
13-
false <- string_is_nil_or_empty(custom_login_subject) do
14-
custom_login_subject
15-
else
16-
_ ->
17-
"Your #{app_name} Sign-In Link"
18-
end
13+
if string_is_nil_or_empty(custom_login_subject),
14+
do: "Your #{app_name} Sign-In Link",
15+
else: custom_login_subject
1916

2017
email_body =
21-
with custom_login_body <-
22-
AppConfig.get_cached_config_value("auth|login_body"),
23-
false <- string_is_nil_or_empty(custom_login_body) do
24-
add_magic_link_to_custom_login_body(custom_login_body, signin_args)
25-
else
26-
_ ->
18+
if string_is_nil_or_empty(custom_login_body),
19+
do:
2720
"To sign-in to #{app_name}, please visit the link below. If you did not make this request, please ignore this e-mail.\n\n #{
2821
RetWeb.Endpoint.url()
29-
}/?#{URI.encode_query(signin_args)}"
30-
end
22+
}/?#{URI.encode_query(signin_args)}",
23+
else: add_magic_link_to_custom_login_body(custom_login_body, signin_args)
3124

3225
email =
3326
new_email()
@@ -51,7 +44,7 @@ defmodule RetWeb.Email do
5144
magic_link = "#{RetWeb.Endpoint.url()}/?#{URI.encode_query(signin_args)}"
5245

5346
if Regex.match?(~r/{{ link }}/, custom_message) do
54-
Regex.replace(~r/{{ link }}/, custom_message, magic_link, global: false)
47+
Regex.replace(~r/{{ link }}/, custom_message, magic_link)
5548
else
5649
custom_message <> "\n\n" <> magic_link
5750
end

0 commit comments

Comments
 (0)