Skip to content
This repository has been archived by the owner on Mar 7, 2018. It is now read-only.

set auth_token to a generated UUID if AUTH_TOKEN not passed in ENV #247

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions templates/project/config.ru
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
require 'dashing'
require 'securerandom'

configure do
set :auth_token, 'YOUR_AUTH_TOKEN'
set :auth_token, ENV['AUTH_TOKEN'] || SecureRandom.uuid
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ENV.fetch('AUTH_TOKEN') { SecureRandom.uuid }

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are subtle differences...

@y = 0
def y
  @y += 1
end
Example X is unset X is anything X is nil unset, second call
`ENV["X"] y` 1 {anything}
ENV.fetch("X") { y } 1 {anything} nil 2
ENV.fetch("X", y) 1 {anything} nil 1


helpers do
def protected!
Expand All @@ -15,4 +16,4 @@ map Sinatra::Application.assets_prefix do
run Sinatra::Application.sprockets
end

run Sinatra::Application
run Sinatra::Application