ruby 2.3.0 + use aliases to pass SMTP settings to the email service
did
committed Dec 06, 2016
commit d7f8e4d5f7c922b391dcb03719da3831f5870af9
Showing 5
changed files with
29 additions
and 7 deletions
Gemfile
+1
-1
| @@ | @@ -35,5 +35,5 @@ group :test do |
| end | |
| platform :ruby do | |
| - | ruby '2.2.3' |
| + | ruby '2.3.0' |
| end | |
locomotive/steam/middlewares/auth.rb b/lib/locomotive/steam/middlewares/auth.rb
+12
-5
| @@ | @@ -17,7 +17,7 @@ module Locomotive::Steam |
| def _call | |
| load_authenticated_entry | |
| - | auth_options = AuthOptions.new(params) |
| + | auth_options = AuthOptions.new(site, params) |
| return unless auth_options.valid? | |
| @@ | @@ -104,10 +104,10 @@ module Locomotive::Steam |
| ACTIONS = %w(sign_in sign_out forgot_password reset_password) | |
| - | attr_reader :params |
| + | attr_reader :site, :params |
| - | def initialize(params) |
| - | @params = params |
| + | def initialize(site, params) |
| + | @site, @params = site, params |
| end | |
| def valid? | |
| @@ | @@ -163,10 +163,17 @@ module Locomotive::Steam |
| end | |
| def smtp | |
| - | namespace = site.metafields[params[:auth_email_smtp_namespace]] || 'smtp' |
| + | name = params[:auth_email_smtp_namespace] || 'smtp' |
| + | namespace = site.metafields.try(:[], name) |
| + | |
| + | if namespace.blank? |
| + | Locomotive::Common::Logger.error "[Auth] Missing SMTP settings in the Site metafields. Namespace: #{name}".light_red |
| + | return {} |
| + | end |
| { | |
| address: namespace[params[:auth_email_smtp_address_alias] || 'address'], | |
| + | port: namespace[params[:auth_email_smtp_port_alias] || 'port'], |
| user_name: namespace[params[:auth_email_smtp_user_name_alias] || 'user_name'], | |
| password: namespace[params[:auth_email_smtp_password_alias] || 'password'] | |
| } | |
spec/fixtures/default/config/metafields_schema.yml
+10
-0
| @@ | @@ -31,3 +31,13 @@ github: |
| min: 0 | |
| max: 3600 | |
| + | smtp: |
| + | fields: |
| + | address: |
| + | type: string |
| + | localhost: |
| + | type: string |
| + | user_name: |
| + | type: string |
| + | password: |
| + | type: string |
spec/fixtures/default/config/site.yml
+5
-0
| @@ | @@ -32,3 +32,8 @@ metafields: |
| github: | |
| api_url: https://api.github.com/repos/vmg/redcarpet/issues?state=closed | |
| expires_in: 42 | |
| + | smtp: |
| + | address: localhost |
| + | port: 25 |
| + | user_name: user |
| + | password: password |
spec/unit/adapters/filesystem/yaml_loaders/site_spec.rb
+1
-1
| @@ | @@ -19,7 +19,7 @@ describe Locomotive::Steam::Adapters::Filesystem::YAMLLoaders::Site do |
| subject { loader.load(nil).first[:metafields_schema] } | |
| it 'loads the full schema' do | |
| - | expect(subject.count).to eq 3 |
| + | expect(subject.count).to eq 4 |
| end | |
| end | |