Skip to content

Commit

Permalink
use ENV variable for sandox use
Browse files Browse the repository at this point in the history
  • Loading branch information
bencornelis committed Sep 15, 2015
1 parent b4e3f1f commit 36d4f85
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ WUNDERLIST_OAUTH_SECRET=

EVERNOTE_OAUTH_KEY=
EVERNOTE_OAUTH_SECRET=
# Set to true in development, false in production
USE_EVERNOTE_SANDBOX=true

#############################
# AWS and Mechanical Turk #
Expand Down
7 changes: 5 additions & 2 deletions app/concerns/evernote_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@ def evernote_client
token: evernote_oauth_token,
consumer_key: evernote_consumer_key,
consumer_secret: evernote_consumer_secret,
# set to false in production
sandbox: true
sandbox: use_sandbox?
)
end

private

def use_sandbox?
ENV["USE_EVERNOTE_SANDBOX"] == "true"
end

def validate_evernote_options
unless evernote_consumer_key.present? &&
evernote_consumer_secret.present? &&
Expand Down
11 changes: 6 additions & 5 deletions config/initializers/devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,12 @@
if defined?(OmniAuth::Strategies::Evernote) &&
(key = ENV["EVERNOTE_OAUTH_KEY"]).present? &&
(secret = ENV["EVERNOTE_OAUTH_SECRET"]).present?
# for development:
config.omniauth :evernote, key, secret, client_options: { :site => 'https://sandbox.evernote.com' }

# for production:
# config.omniauth :evernote, key, secret

if ENV["USE_EVERNOTE_SANDBOX"] == "true"
config.omniauth :evernote, key, secret, client_options: { :site => 'https://sandbox.evernote.com' }
else
config.omniauth :evernote, key, secret
end
end

# ==> Warden configuration
Expand Down

0 comments on commit 36d4f85

Please sign in to comment.