summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2012-01-17 17:18:41 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2012-01-17 17:18:41 +0100
commitd0a23c4920794c9f8dd4189d7432a6b49da898d8 (patch)
treea4ae0397d8b3e044caa1948c3cd8eeacff158b23 /lib
parentd306318eab974e596d9ae07d7ab4f9170ce025f7 (diff)
downloadzorglub-d0a23c4920794c9f8dd4189d7432a6b49da898d8.zip
zorglub-d0a23c4920794c9f8dd4189d7432a6b49da898d8.tar.gz
App: remove session_ prefix from session_options keys
Diffstat (limited to 'lib')
-rw-r--r--lib/zorglub/app.rb8
-rw-r--r--lib/zorglub/session.rb12
2 files changed, 10 insertions, 10 deletions
diff --git a/lib/zorglub/app.rb b/lib/zorglub/app.rb
index 2be2f6b..553dd3f 100644
--- a/lib/zorglub/app.rb
+++ b/lib/zorglub/app.rb
@@ -26,10 +26,10 @@ module Zorglub
:encoding => 'utf-8'
},
:session_options => {
- :session_on => false,
- :session_key => 'zorglub.sid',
- :session_secret => 'session-secret-secret',
- :session_sid_len => 64,
+ :enabled => false,
+ :key => 'zorglub.sid',
+ :secret => 'session-secret-secret',
+ :sid_len => 64,
}
}
instance_eval &block if block_given?
diff --git a/lib/zorglub/session.rb b/lib/zorglub/session.rb
index 7e91555..7351a48 100644
--- a/lib/zorglub/session.rb
+++ b/lib/zorglub/session.rb
@@ -47,7 +47,7 @@ module Zorglub
#
def clear
load_data!
-# @response.delete_cookie @options[:session_key]
+# @response.delete_cookie @options[:key]
# @sessions.delete @sid
# @sid = nil
super
@@ -95,11 +95,11 @@ module Zorglub
#
def load_data!
return if loaded?
- if @options[:session_on]
- sid = @request.cookies[@options[:session_key]]
+ if @options[:enabled]
+ sid = @request.cookies[@options[:key]]
if sid.nil?
sid = generate_sid!
- @response.set_cookie @options[:session_key], sid
+ @response.set_cookie @options[:key], sid
end
replace @sessions[sid] ||={}
@sessions[sid] = self
@@ -126,7 +126,7 @@ module Zorglub
# SecureRandom is available since Ruby 1.8.7.
# For Ruby versions earlier than that, you can require the uuidtools gem,
# which has a drop-in replacement for SecureRandom.
- def sid_algorithm; SecureRandom.hex(@options[:session_sid_len]); end
+ def sid_algorithm; SecureRandom.hex(@options[:sid_len]); end
rescue LoadError
require 'openssl'
# Using OpenSSL::Random for generation, this is comparable in performance
@@ -134,7 +134,7 @@ module Zorglub
# have the same behaviour as the SecureRandom::hex method of the
# uuidtools gem.
def sid_algorithm
- OpenSSL::Random.random_bytes(@options[:session_sid_len] / 2).unpack('H*')[0]
+ OpenSSL::Random.random_bytes(@options[:sid_len] / 2).unpack('H*')[0]
end
rescue LoadError
# Digest::SHA2::hexdigest produces a string of length 64, although