@@ -6,28 +6,21 @@ defmodule RetWeb.Email do
6
6
app_name = AppConfig . get_cached_config_value ( "translations|en|app-name" )
7
7
app_full_name = AppConfig . get_cached_config_value ( "translations|en|app-full-name" ) || app_name
8
8
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" )
9
11
10
12
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
19
16
20
17
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:
27
20
"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 #{
28
21
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 )
31
24
32
25
email =
33
26
new_email ( )
@@ -51,7 +44,7 @@ defmodule RetWeb.Email do
51
44
magic_link = "#{ RetWeb.Endpoint . url ( ) } /?#{ URI . encode_query ( signin_args ) } "
52
45
53
46
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 )
55
48
else
56
49
custom_message <> "\n \n " <> magic_link
57
50
end
0 commit comments