mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Simplify SMTP auth method selection
Instead of using the auth method name, let's just not supply username and password when we don't want to authenticate. The two affected servers AU and CA don't have credentials set anyway. This is compatible. The specs needed changing though.
This commit is contained in:
@@ -20,18 +20,14 @@ module Spree
|
||||
private
|
||||
|
||||
def mail_server_settings
|
||||
settings = if need_authentication?
|
||||
basic_settings.merge(user_credentials)
|
||||
else
|
||||
basic_settings
|
||||
end
|
||||
settings = basic_settings.merge(user_credentials)
|
||||
|
||||
settings.merge(enable_starttls_auto: secure_connection?)
|
||||
end
|
||||
|
||||
def user_credentials
|
||||
{ user_name: Config.smtp_username,
|
||||
password: Config.smtp_password }
|
||||
{ user_name: Config.smtp_username.presence,
|
||||
password: Config.smtp_password.presence }
|
||||
end
|
||||
|
||||
def basic_settings
|
||||
@@ -42,13 +38,10 @@ module Spree
|
||||
end
|
||||
|
||||
def authentication
|
||||
return unless need_authentication?
|
||||
|
||||
Config.mail_auth_type.presence
|
||||
end
|
||||
|
||||
def need_authentication?
|
||||
Config.mail_auth_type != 'None'
|
||||
# "None" is an option in the UI but not a real authentication type.
|
||||
# We should remove it from our host configurations but I'm keeping
|
||||
# this check for backwards-compatibility for now.
|
||||
Config.mail_auth_type.presence unless Config.mail_auth_type == "None"
|
||||
end
|
||||
|
||||
def secure_connection?
|
||||
|
||||
Reference in New Issue
Block a user