challah 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d5dd9f7607415478ba95197e94b636bf004fa112
4
- data.tar.gz: 8eee2c44ece6a0791b97cb84e31150318ae13304
3
+ metadata.gz: f03909894b61ef1fdbfc44ee6f84b221e10abe97
4
+ data.tar.gz: 66cb9a87b30a57581d45afaebdcde5e8e748b81f
5
5
  SHA512:
6
- metadata.gz: 6b9275f0926d1242f954a94103e6fb1df0026c69822af518f0453fcf1012b7dd2b802645b93aefdf275d05524a083e2715f7331de095751f14a8358c1e18eebb
7
- data.tar.gz: b215eaeb180a41a500ab9a0e690942c4a9237094fe320711f6c4354e349f3bf1fab2948489554b8c64219208b9e308af1ef2f5f21cbad3885012bdaced7240c4
6
+ metadata.gz: c392131e19fa54603ffda28f8466888440635c71a97e55ff1401c02efb0faab5e46ed6d2089e86cf083ab03410e0bf88fdb71621191d7aadccc29642243be6d3
7
+ data.tar.gz: 1db8e607039db9d51cd02d9f9de641f7756a92f034331b96a73d7e93b43144f8ae6c7c88564a6856d2bce7d51c67dc0ea980daba5ee31b064ab903905f0091a9
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## Challah 1.2.2
2
+
3
+ * Bug fix for “A copy of User has been removed from the module tree but is still active!” error in Rails development mode. Fix was to not cache the `User` model reference from within the engine.
4
+
1
5
  ## Challah 1.2.1
2
6
 
3
7
  * Bug fixed when loading `challah/test` in minitest.
data/lib/challah.rb CHANGED
@@ -60,7 +60,7 @@ module Challah
60
60
  end
61
61
 
62
62
  def self.user
63
- @user ||= options[:user].to_s.safe_constantize
63
+ options[:user].to_s.safe_constantize
64
64
  end
65
65
 
66
66
  # Set up techniques engines
data/lib/challah/audit.rb CHANGED
@@ -1,10 +1,10 @@
1
1
  module Challah
2
- # The audit methods are included into ActiveRecord::Base automatically and add
3
- # basic audit trail functionality for your models. Certain columns will be
2
+ # The audit methods are included into ActiveRecord::Base automatically and add
3
+ # basic audit trail functionality for your models. Certain columns will be
4
4
  # updated with the current user's id if provided at save time.
5
5
  #
6
6
  # For new records, the following fields will be updated if +current_user+ is provided:
7
- #
7
+ #
8
8
  # * created_by
9
9
  # * created_user_id
10
10
  #
@@ -28,17 +28,17 @@ module Challah
28
28
  # end
29
29
  #
30
30
  module Audit
31
- def self.included(base)
32
- base.class_eval do
33
- before_save :before_save_audit
34
- end
31
+ extend ActiveSupport::Concern
32
+
33
+ included do
34
+ before_save :before_save_audit
35
35
  end
36
-
36
+
37
37
  # @private
38
38
  def initialize_dup(other)
39
39
  clear_audit_attributes
40
40
  end
41
-
41
+
42
42
  def current_user=(value)
43
43
  @current_user_id = (Object === value ? value[:id] : value)
44
44
  end
@@ -54,53 +54,54 @@ module Challah
54
54
 
55
55
  @current_user_id
56
56
  end
57
-
57
+
58
58
  private
59
- def before_save_audit
60
- if new_record?
61
- all_audit_attributes.each do |attr_name|
62
- attr_name = attr_name.to_s
63
- column = column_for_attribute(attr_name)
64
59
 
65
- if column || @attributes.has_key?(attr_name)
66
- write_attribute(attr_name, current_user_id)
67
- end
60
+ def before_save_audit
61
+ if new_record?
62
+ all_audit_attributes.each do |attr_name|
63
+ attr_name = attr_name.to_s
64
+ column = column_for_attribute(attr_name)
65
+
66
+ if column || @attributes.has_key?(attr_name)
67
+ write_attribute(attr_name, current_user_id)
68
68
  end
69
- else
70
- audit_attributes_for_update.each do |column|
71
- if respond_to?(column) && respond_to?("#{column}=")
72
- column = column.to_s
73
- next if attribute_changed?(column) # don't update the column if we already manually did
74
- write_attribute(column, current_user_id)
75
- end
69
+ end
70
+ else
71
+ audit_attributes_for_update.each do |column|
72
+ if respond_to?(column) && respond_to?("#{ column }=")
73
+ column = column.to_s
74
+ next if attribute_changed?(column) # don't update the column if we already manually did
75
+ write_attribute(column, current_user_id)
76
76
  end
77
77
  end
78
78
  end
79
-
80
- # @private
81
- def audit_attributes_for_update
82
- [ :updated_by, :modifed_by, :updated_user_id ]
83
- end
84
-
85
- # @private
86
- def audit_attributes_for_create
87
- [ :created_by, :created_user_id ]
88
- end
89
-
90
- # @private
91
- def all_audit_attributes
92
- audit_attributes_for_update + audit_attributes_for_create
93
- end
94
-
95
- # Clear attributes and changed_attributes
96
- def clear_audit_attributes
97
- all_audit_attributes.each do |attribute_name|
98
- if respond_to?(attribute_name) && respond_to?("#{attribute_name}=")
99
- write_attribute(attribute_name, nil)
100
- end
101
-
102
- changed_attributes.delete(attribute_name)
79
+ end
80
+
81
+ # @private
82
+ def audit_attributes_for_update
83
+ [ :updated_by, :modifed_by, :updated_user_id ]
84
+ end
85
+
86
+ # @private
87
+ def audit_attributes_for_create
88
+ [ :created_by, :created_user_id ]
89
+ end
90
+
91
+ # @private
92
+ def all_audit_attributes
93
+ audit_attributes_for_update + audit_attributes_for_create
94
+ end
95
+
96
+ # Clear attributes and changed_attributes
97
+ def clear_audit_attributes
98
+ all_audit_attributes.each do |attribute_name|
99
+ if respond_to?(attribute_name) && respond_to?("#{ attribute_name }=")
100
+ write_attribute(attribute_name, nil)
103
101
  end
102
+
103
+ changed_attributes.delete(attribute_name)
104
104
  end
105
+ end
105
106
  end
106
- end
107
+ end
@@ -14,32 +14,30 @@ module Challah
14
14
  # Find a user instance by username first, or email address if needed.
15
15
  # If no user is found matching, return nil
16
16
  def find_for_session(username_or_email)
17
- return nil if username_or_email.to_s.blank?
17
+ return if username_or_email.to_s.blank?
18
18
 
19
- result = nil
20
-
21
- if username_or_email.to_s.include?('@')
22
- result = where(email: username_or_email).first
23
- end
19
+ username_or_email = username_or_email.downcase.strip
20
+ find_by_email(username_or_email) || find_by_authorization(username_or_email)
21
+ end
24
22
 
25
- if !result
26
- uid = username_or_email.to_s.downcase.strip
23
+ def inactive
24
+ where.not(active: true)
25
+ end
27
26
 
28
- authorization = self.authorization_model
29
- authorization = authorization.where(provider: :password, uid: uid)
30
- authorization = authorization.first
27
+ protected
31
28
 
32
- if authorization
33
- result = authorization.user
34
- end
29
+ def find_by_authorization(uid)
30
+ authorization = self.authorization_model
31
+ result = authorization.where(provider: :password, uid: uid).first
32
+ if result
33
+ result.user
35
34
  end
36
-
37
- result
38
35
  end
39
36
 
40
- def inactive
41
- where.not(active: true)
37
+ def find_by_email(email)
38
+ return unless email.include?('@')
39
+ where(email: email).first
42
40
  end
43
41
  end
44
42
  end
45
- end
43
+ end
@@ -2,10 +2,10 @@ module Challah
2
2
  # These methods are added into ActionController::Base and are available in all
3
3
  # of your app's controllers.
4
4
  module Controller
5
- # @private
6
- def self.included(base)
7
- base.send(:include, InstanceMethods)
8
- base.send(:extend, ClassMethods)
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ extend ClassMethods
9
9
  end
10
10
 
11
11
  module ClassMethods
@@ -41,79 +41,78 @@ module Challah
41
41
  alias_method :login_required, :signin_required
42
42
  end
43
43
 
44
- module InstanceMethods
45
- protected
46
- # Is there currently a logged in user? Returns true if it is safe to use
47
- # the {#current_user current_user} method.
48
- #
49
- # @note This method is also available as a helper in your views.
50
- #
51
- # @see #current_user current_user
52
- #
53
- # @return [Boolean] Is there a user logged in?
54
- def current_user?
55
- !!current_user
56
- end
44
+ protected
57
45
 
58
- # Alias for current_user?
59
- def signed_in?
60
- current_user?
61
- end
62
- alias_method :logged_in?, :signed_in?
46
+ # Is there currently a logged in user? Returns true if it is safe to use
47
+ # the {#current_user current_user} method.
48
+ #
49
+ # @note This method is also available as a helper in your views.
50
+ #
51
+ # @see #current_user current_user
52
+ #
53
+ # @return [Boolean] Is there a user logged in?
54
+ def current_user?
55
+ !!current_user
56
+ end
63
57
 
64
- # The user that is currently logged into this session. If there is no
65
- # user logged in, nil will be returned.
66
- #
67
- # @note This method is also available as a helper in your views.
68
- #
69
- # @return [User, nil] The current authenticated user.
70
- def current_user
71
- @current_user ||= current_user_session.user
72
- end
58
+ # Alias for current_user?
59
+ def signed_in?
60
+ current_user?
61
+ end
62
+ alias_method :logged_in?, :signed_in?
73
63
 
74
- # The current authentication session, if one exists. A {Session} object will be
75
- # returned regardless of its valid status. If an invalid session is returned, the
76
- # {Session#user user} attribute will be nil.
77
- #
78
- # @return [Session] The current browser session.
79
- def current_user_session
80
- @current_user_session ||= Challah::Session.find(request, params, user_model)
81
- end
64
+ # The user that is currently logged into this session. If there is no
65
+ # user logged in, nil will be returned.
66
+ #
67
+ # @note This method is also available as a helper in your views.
68
+ #
69
+ # @return [User, nil] The current authenticated user.
70
+ def current_user
71
+ @current_user ||= current_user_session.user
72
+ end
82
73
 
83
- # Restrict a controller to only authenticated users. If someone tries to access
84
- # a restricted action and is not logged in, they will be redirected to the
85
- # login page.
86
- #
87
- # This method is an alias for:
88
- #
89
- # restrict_to_authenticated
90
- #
91
- # @example
92
- # class YourController < ApplicationController
93
- # before_filter :login_required
94
- #
95
- # # ...
96
- # end
97
- #
98
- # @example Specifing certain actions.
99
- # class YourOtherController < ApplicationController
100
- # before_filter :login_required, :only => [ :create, :update, :destroy ]
101
- #
102
- # # ...
103
- # end
104
- #
105
- # @see Controller::ClassMethods#restrict_to_authenticated restrict_to_authenticated
106
- def signin_required
107
- unless signed_in?
108
- session[:return_to] = request.url
109
- redirect_to signin_path and return
110
- end
111
- end
112
- alias_method :login_required, :signin_required
74
+ # The current authentication session, if one exists. A {Session} object will be
75
+ # returned regardless of its valid status. If an invalid session is returned, the
76
+ # {Session#user user} attribute will be nil.
77
+ #
78
+ # @return [Session] The current browser session.
79
+ def current_user_session
80
+ @current_user_session ||= Challah::Session.find(request, params, user_model)
81
+ end
113
82
 
114
- def user_model
115
- @_user_model ||= Challah.user
116
- end
83
+ # Restrict a controller to only authenticated users. If someone tries to access
84
+ # a restricted action and is not logged in, they will be redirected to the
85
+ # login page.
86
+ #
87
+ # This method is an alias for:
88
+ #
89
+ # restrict_to_authenticated
90
+ #
91
+ # @example
92
+ # class YourController < ApplicationController
93
+ # before_filter :login_required
94
+ #
95
+ # # ...
96
+ # end
97
+ #
98
+ # @example Specifing certain actions.
99
+ # class YourOtherController < ApplicationController
100
+ # before_filter :login_required, :only => [ :create, :update, :destroy ]
101
+ #
102
+ # # ...
103
+ # end
104
+ #
105
+ # @see Controller::ClassMethods#restrict_to_authenticated restrict_to_authenticated
106
+ def signin_required
107
+ unless signed_in?
108
+ session[:return_to] = request.url
109
+ redirect_to signin_path and return
110
+ end
111
+ end
112
+ alias_method :login_required, :signin_required
113
+
114
+ def user_model
115
+ @_challah_user_model ||= Challah.user
117
116
  end
118
117
  end
119
- end
118
+ end
@@ -14,9 +14,10 @@ module Challah
14
14
  end
15
15
 
16
16
  protected
17
- def validation_cookie_value(value = nil)
18
- value = session_cookie_value unless value
19
- Encrypter.md5(value, request.user_agent, request.remote_ip)
20
- end
17
+
18
+ def validation_cookie_value(value = nil)
19
+ value = session_cookie_value unless value
20
+ Encrypter.md5(value, request.user_agent, request.remote_ip)
21
+ end
21
22
  end
22
- end
23
+ end
@@ -39,11 +39,20 @@ module Challah
39
39
  false
40
40
  end
41
41
 
42
- class << self
43
- # Setup some pass through convenience methods that use default options
44
- %w( hash md5 encrypt compare ).each do |f|
45
- class_eval "def #{f}(*args); new.#{f}(*args); end"
46
- end
42
+ def self.compare(*args)
43
+ new().compare(*args)
44
+ end
45
+
46
+ def self.encrypt(*args)
47
+ new().encrypt(*args)
48
+ end
49
+
50
+ def self.hash(*args)
51
+ new().hash(*args)
52
+ end
53
+
54
+ def self.md5(*args)
55
+ new().md5(*args)
47
56
  end
48
57
  end
49
58
  end
@@ -1,5 +1,4 @@
1
1
  module Challah
2
-
3
2
  class Engine < ::Rails::Engine
4
3
 
5
4
  initializer 'challah.router' do |app|
@@ -18,45 +17,42 @@ module Challah
18
17
  end
19
18
  end
20
19
 
21
- class << self
22
- # Set up controller methods
23
- def setup_action_controller!
24
- if defined?(ActionController)
25
- ActionController::Base.send(:include, Challah::Controller)
26
- ActionController::Base.send(:helper_method,
27
- :current_user_session,
28
- :current_user,
29
- :current_user?,
30
- :logged_in?,
31
- :signed_in?
32
- )
33
-
34
- # Load any ActionController/Challah plugins
35
- Challah.plugins.values.each do |plugin|
36
- plugin.action_controller.each do |proc|
37
- proc.call
38
- end
20
+ # Set up controller methods
21
+ def self.setup_action_controller!
22
+ if defined?(ActionController)
23
+ ActionController::Base.send(:include, Challah::Controller)
24
+ ActionController::Base.send(:helper_method,
25
+ :current_user_session,
26
+ :current_user,
27
+ :current_user?,
28
+ :logged_in?,
29
+ :signed_in?
30
+ )
31
+
32
+ # Load any ActionController/Challah plugins
33
+ Challah.plugins.values.each do |plugin|
34
+ plugin.action_controller.each do |proc|
35
+ proc.call
39
36
  end
40
37
  end
41
38
  end
39
+ end
42
40
 
43
- # Set up active record with Challah methods
44
- def setup_active_record!
45
- if defined?(ActiveRecord)
46
- Challah.options[:logger] = ActiveRecord::Base.logger
41
+ # Set up active record with Challah methods
42
+ def self.setup_active_record!
43
+ if defined?(ActiveRecord)
44
+ Challah.options[:logger] = ActiveRecord::Base.logger
47
45
 
48
- ActiveRecord::Base.send(:include, Challah::ActiveRecordExtensions)
49
- ActiveRecord::Base.send(:include, Challah::Audit)
46
+ ActiveRecord::Base.send(:include, Challah::ActiveRecordExtensions)
47
+ ActiveRecord::Base.send(:include, Challah::Audit)
50
48
 
51
- # Load any ActiveRecord/Challah plugins
52
- Challah.plugins.values.each do |plugin|
53
- plugin.active_record.each do |proc|
54
- proc.call
55
- end
49
+ # Load any ActiveRecord/Challah plugins
50
+ Challah.plugins.values.each do |plugin|
51
+ plugin.active_record.each do |proc|
52
+ proc.call
56
53
  end
57
54
  end
58
55
  end
59
56
  end
60
57
  end
61
-
62
58
  end
@@ -96,72 +96,71 @@ module Challah
96
96
  super(sym, *args, &block)
97
97
  end
98
98
 
99
- class << self
100
- # Manually create a new Session
101
- def create(user_or_user_id, request = nil, params = nil, user_model = nil)
102
- user_model = Challah.user if user_model.nil?
99
+ # Manually create a new Session
100
+ def self.create(user_or_user_id, request = nil, params = nil, user_model = nil)
101
+ user_model = Challah.user if user_model.nil?
103
102
 
104
- user_record = user_model === user_or_user_id ? user_or_user_id : user_model.find_by_id(user_or_user_id)
103
+ user_record = user_model === user_or_user_id ? user_or_user_id : user_model.find_by_id(user_or_user_id)
105
104
 
106
- session = Session.new(request, params, user_model)
105
+ session = Session.new(request, params, user_model)
107
106
 
108
- if user_record and user_record.active?
109
- session.user = user_record
110
- session.persist = true
111
- end
112
-
113
- session
107
+ if user_record and user_record.active?
108
+ session.user = user_record
109
+ session.persist = true
114
110
  end
115
111
 
116
- # Manually create a session, and save it.
117
- def create!(user_or_user_id, request = nil, params = nil, user_model = nil)
118
- session = create(user_or_user_id, request, params, user_model)
119
- session.save
120
- session
121
- end
112
+ session
113
+ end
122
114
 
123
- # Clear out any existing sessions
124
- def destroy
125
- session = Session.find
126
- session.destroy if session
127
- session
128
- end
115
+ # Manually create a session, and save it.
116
+ def self.create!(user_or_user_id, request = nil, params = nil, user_model = nil)
117
+ session = create(user_or_user_id, request, params, user_model)
118
+ session.save
119
+ session
120
+ end
129
121
 
130
- # Load any existing session from the session store
131
- def find(*args)
132
- session = Session.new(*args)
133
- session.find
134
- session
135
- end
122
+ # Clear out any existing sessions
123
+ def self.destroy
124
+ session = Session.find
125
+ session.destroy if session
126
+ session
127
+ end
128
+
129
+ # Load any existing session from the session store
130
+ def self.find(*args)
131
+ session = Session.new(*args)
132
+ session.find
133
+ session
136
134
  end
137
135
 
138
136
  protected
139
- # Try and authenticate against the various auth techniques. If one
140
- # technique works, then just exist and make the session active.
141
- def authenticate!
142
- Challah.techniques.values.each do |klass|
143
- technique = klass.new(self)
144
- technique.user_model = user_model if technique.respond_to?(:"user_model=")
145
-
146
- @user = technique.authenticate
147
-
148
- if @user
149
- @persist = technique.respond_to?(:persist?) ? technique.persist? : false
150
- break
151
- end
152
- end
137
+
138
+ # Try and authenticate against the various auth techniques. If one
139
+ # technique works, then just exist and make the session active.
140
+ def authenticate!
141
+ Challah.techniques.values.each do |klass|
142
+ technique = klass.new(self)
143
+ technique.user_model = user_model if technique.respond_to?(:"user_model=")
144
+
145
+ @user = technique.authenticate
153
146
 
154
147
  if @user
155
- # Only update user record if persistence is on for the technique.
156
- # Otherwise this builds up quick (one session for each API call)
157
- if @persist
158
- @user.successful_authentication!(ip)
159
- end
148
+ @persist = technique.respond_to?(:persist?) ? technique.persist? : false
149
+ break
150
+ end
151
+ end
160
152
 
161
- return @valid = true
153
+ if @user
154
+ # Only update user record if persistence is on for the technique.
155
+ # Otherwise this builds up quick (one session for each API call)
156
+ if @persist
157
+ @user.successful_authentication!(ip)
162
158
  end
163
159
 
164
- @valid = false
160
+ return @valid = true
165
161
  end
162
+
163
+ @valid = false
164
+ end
166
165
  end
167
- end
166
+ end
@@ -28,107 +28,108 @@ module Challah
28
28
  end
29
29
 
30
30
  private
31
- def clear
32
- cookies.delete(session_cookie_name, domain: domain)
33
- cookies.delete(validation_cookie_name, domain: domain)
34
- end
35
31
 
36
- def cookie_values
37
- session_cookie && session_cookie.to_s.split(joiner)
38
- end
32
+ def clear
33
+ cookies.delete(session_cookie_name, domain: domain)
34
+ cookies.delete(validation_cookie_name, domain: domain)
35
+ end
39
36
 
40
- def cookies
41
- request.cookie_jar
42
- end
37
+ def cookie_values
38
+ session_cookie && session_cookie.to_s.split(joiner)
39
+ end
43
40
 
44
- def default_cookie_prefix
45
- Challah.options[:cookie_prefix]
46
- end
41
+ def cookies
42
+ request.cookie_jar
43
+ end
47
44
 
48
- def domain
49
- request.session_options[:domain]
50
- end
45
+ def default_cookie_prefix
46
+ Challah.options[:cookie_prefix]
47
+ end
51
48
 
52
- # Do the cookies exist, and are they valid?
53
- def existing?
54
- exists = false
49
+ def domain
50
+ request.session_options[:domain]
51
+ end
55
52
 
56
- if session_cookie and validation_cookie
57
- session_tmp = session_cookie.to_s
58
- validation_tmp = validation_cookie.to_s
53
+ # Do the cookies exist, and are they valid?
54
+ def existing?
55
+ exists = false
59
56
 
60
- if validation_tmp == validation_cookie_value(session_tmp)
61
- exists = true
62
- end
63
- end
57
+ if session_cookie and validation_cookie
58
+ session_tmp = session_cookie.to_s
59
+ validation_tmp = validation_cookie.to_s
64
60
 
65
- exists
61
+ if validation_tmp == validation_cookie_value(session_tmp)
62
+ exists = true
63
+ end
66
64
  end
67
65
 
68
- def expiration
69
- @expiration ||= 1.month.from_now
70
- end
66
+ exists
67
+ end
71
68
 
72
- def joiner
73
- '@'
74
- end
69
+ def expiration
70
+ @expiration ||= 1.month.from_now
71
+ end
75
72
 
76
- def prefix
77
- @prefix ||= [ default_cookie_prefix, user_model_id ].compact.join('-')
78
- end
73
+ def joiner
74
+ '@'
75
+ end
79
76
 
80
- def request
81
- raise "No Request Provided" unless @session and @session.request
82
- @session.request
83
- end
77
+ def prefix
78
+ @prefix ||= [ default_cookie_prefix, user_model_id ].compact.join('-')
79
+ end
84
80
 
85
- def session_cookie
86
- cookies[session_cookie_name]
87
- end
81
+ def request
82
+ raise "No Request Provided" unless @session and @session.request
83
+ @session.request
84
+ end
88
85
 
89
- def session_cookie_name
90
- "#{prefix}-s"
91
- end
86
+ def session_cookie
87
+ cookies[session_cookie_name]
88
+ end
92
89
 
93
- def session_cookie_value
94
- "#@token#{joiner}#@user_id"
95
- end
90
+ def session_cookie_name
91
+ "#{prefix}-s"
92
+ end
96
93
 
97
- def user_model_id
98
- if @session && @session.user_model && @session.user_model.table_name != 'users'
99
- Encrypter.md5(@session.user_model.table_name).slice(0..5)
100
- end
101
- end
94
+ def session_cookie_value
95
+ "#@token#{joiner}#@user_id"
96
+ end
102
97
 
103
- def validation_cookie
104
- cookies[validation_cookie_name]
98
+ def user_model_id
99
+ if @session && @session.user_model && @session.user_model.table_name != 'users'
100
+ Encrypter.md5(@session.user_model.table_name).slice(0..5)
105
101
  end
102
+ end
106
103
 
107
- def validation_cookie_name
108
- "#{prefix}-v"
109
- end
104
+ def validation_cookie
105
+ cookies[validation_cookie_name]
106
+ end
110
107
 
111
- def validation_cookie_value(value = nil)
112
- value = session_cookie_value unless value
113
- Encrypter.md5(value)
114
- end
108
+ def validation_cookie_name
109
+ "#{prefix}-v"
110
+ end
115
111
 
116
- def write_cookies!
117
- cookies[session_cookie_name] = {
118
- value: session_cookie_value,
119
- expires: expiration,
120
- secure: false,
121
- httponly: true,
122
- domain: domain
123
- }
124
-
125
- cookies[validation_cookie_name] = {
126
- value: validation_cookie_value,
127
- expires: expiration,
128
- secure: false,
129
- httponly: true,
130
- domain: domain
131
- }
132
- end
112
+ def validation_cookie_value(value = nil)
113
+ value = session_cookie_value unless value
114
+ Encrypter.md5(value)
115
+ end
116
+
117
+ def write_cookies!
118
+ cookies[session_cookie_name] = {
119
+ value: session_cookie_value,
120
+ expires: expiration,
121
+ secure: false,
122
+ httponly: true,
123
+ domain: domain
124
+ }
125
+
126
+ cookies[validation_cookie_name] = {
127
+ value: validation_cookie_value,
128
+ expires: expiration,
129
+ secure: false,
130
+ httponly: true,
131
+ domain: domain
132
+ }
133
+ end
133
134
  end
134
- end
135
+ end
@@ -1,3 +1,3 @@
1
1
  module Challah
2
- VERSION = "1.2.1" unless defined?(::Challah::VERSION)
2
+ VERSION = "1.2.2" unless defined?(::Challah::VERSION)
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: challah
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Tornow
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-11 00:00:00.000000000 Z
11
+ date: 2014-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  version: '0'
141
141
  requirements: []
142
142
  rubyforge_project:
143
- rubygems_version: 2.0.3
143
+ rubygems_version: 2.0.14
144
144
  signing_key:
145
145
  specification_version: 4
146
146
  summary: Rails 4 authentication and sessions