devise 1.1.rc1 → 1.1.rc2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of devise might be problematic. Click here for more details.
- data/CHANGELOG.rdoc +63 -27
- data/Gemfile +15 -13
- data/README.rdoc +63 -51
- data/Rakefile +3 -2
- data/TODO +1 -0
- data/app/controllers/devise/registrations_controller.rb +1 -1
- data/app/mailers/devise/mailer.rb +43 -43
- data/app/views/devise/confirmations/new.html.erb +2 -2
- data/app/views/devise/passwords/edit.html.erb +4 -4
- data/app/views/devise/passwords/new.html.erb +2 -2
- data/app/views/devise/registrations/edit.html.erb +8 -8
- data/app/views/devise/registrations/new.html.erb +6 -6
- data/app/views/devise/sessions/new.html.erb +4 -4
- data/app/views/devise/unlocks/new.html.erb +2 -2
- data/config/locales/en.yml +7 -4
- data/lib/devise.rb +33 -6
- data/lib/devise/controllers/helpers.rb +38 -2
- data/lib/devise/encryptors/authlogic_sha512.rb +0 -2
- data/lib/devise/encryptors/bcrypt.rb +0 -2
- data/lib/devise/encryptors/clearance_sha1.rb +0 -2
- data/lib/devise/encryptors/sha1.rb +6 -8
- data/lib/devise/encryptors/sha512.rb +6 -8
- data/lib/devise/failure_app.rb +3 -2
- data/lib/devise/hooks/activatable.rb +4 -1
- data/lib/devise/hooks/forgetable.rb +4 -3
- data/lib/devise/hooks/rememberable.rb +6 -2
- data/lib/devise/hooks/timeoutable.rb +6 -2
- data/lib/devise/mapping.rb +7 -8
- data/lib/devise/models.rb +0 -34
- data/lib/devise/models/authenticatable.rb +29 -3
- data/lib/devise/models/confirmable.rb +3 -2
- data/lib/devise/models/database_authenticatable.rb +4 -2
- data/lib/devise/models/lockable.rb +1 -1
- data/lib/devise/models/recoverable.rb +1 -1
- data/lib/devise/models/rememberable.rb +9 -1
- data/lib/devise/orm/active_record.rb +4 -6
- data/lib/devise/orm/data_mapper.rb +5 -7
- data/lib/devise/orm/mongoid.rb +2 -13
- data/lib/devise/path_checker.rb +13 -0
- data/lib/devise/rails.rb +45 -18
- data/lib/devise/rails/routes.rb +24 -7
- data/lib/devise/schema.rb +23 -19
- data/lib/devise/strategies/authenticatable.rb +20 -4
- data/lib/devise/strategies/database_authenticatable.rb +1 -1
- data/lib/devise/strategies/token_authenticatable.rb +2 -2
- data/lib/devise/test_helpers.rb +2 -1
- data/lib/devise/version.rb +1 -1
- data/lib/generators/devise/devise/devise_generator.rb +86 -0
- data/lib/generators/devise/{templates → devise/templates}/migration.rb +2 -2
- data/lib/generators/devise/install/install_generator.rb +24 -0
- data/lib/generators/{devise_install → devise/install}/templates/README +1 -1
- data/lib/generators/{devise_install → devise/install}/templates/devise.rb +37 -18
- data/lib/generators/devise/views/views_generator.rb +63 -0
- data/lib/generators/devise_generator.rb +2 -0
- data/lib/generators/devise_install_generator.rb +4 -0
- data/lib/generators/devise_views_generator.rb +4 -0
- data/test/controllers/helpers_test.rb +15 -0
- data/test/devise_test.rb +1 -0
- data/test/failure_app_test.rb +25 -10
- data/test/integration/authenticatable_test.rb +279 -0
- data/test/integration/database_authenticatable_test.rb +2 -262
- data/test/integration/http_authenticatable_test.rb +7 -9
- data/test/integration/registerable_test.rb +14 -2
- data/test/integration/rememberable_test.rb +15 -3
- data/test/integration/timeoutable_test.rb +12 -0
- data/test/integration/token_authenticatable_test.rb +2 -3
- data/test/mailers/confirmation_instructions_test.rb +2 -2
- data/test/mailers/reset_password_instructions_test.rb +2 -2
- data/test/mailers/unlock_instructions_test.rb +3 -3
- data/test/models/confirmable_test.rb +16 -0
- data/test/models/database_authenticatable_test.rb +20 -20
- data/test/models/lockable_test.rb +1 -1
- data/test/models/rememberable_test.rb +4 -4
- data/test/orm/data_mapper.rb +9 -0
- data/test/rails_app/app/active_record/shim.rb +2 -0
- data/test/rails_app/app/controllers/application_controller.rb +1 -0
- data/test/rails_app/app/controllers/home_controller.rb +3 -0
- data/test/rails_app/app/controllers/users_controller.rb +2 -0
- data/test/rails_app/app/data_mapper/shim.rb +2 -0
- data/test/rails_app/app/data_mapper/user.rb +4 -5
- data/test/rails_app/app/mongoid/admin.rb +1 -10
- data/test/rails_app/app/mongoid/shim.rb +16 -0
- data/test/rails_app/app/mongoid/user.rb +1 -12
- data/test/rails_app/config/application.rb +2 -0
- data/test/rails_app/config/initializers/devise.rb +2 -2
- data/test/rails_app/config/routes.rb +6 -1
- data/test/routes_test.rb +2 -2
- data/test/test_helper.rb +0 -4
- data/test/test_helpers_test.rb +1 -0
- metadata +113 -12
- data/lib/generators/devise/devise_generator.rb +0 -67
- data/lib/generators/devise_install/devise_install_generator.rb +0 -25
- data/lib/generators/devise_views/devise_views_generator.rb +0 -62
@@ -3,8 +3,8 @@
|
|
3
3
|
<%= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name)) do |f| %>
|
4
4
|
<%= devise_error_messages! %>
|
5
5
|
|
6
|
-
<p><%= f.label :email
|
7
|
-
|
6
|
+
<p><%= f.label :email %><br />
|
7
|
+
<%= f.text_field :email %></p>
|
8
8
|
|
9
9
|
<p><%= f.submit "Resend confirmation instructions" %></p>
|
10
10
|
<% end %>
|
@@ -4,11 +4,11 @@
|
|
4
4
|
<%= devise_error_messages! %>
|
5
5
|
<%= f.hidden_field :reset_password_token %>
|
6
6
|
|
7
|
-
<p><%= f.label :password
|
8
|
-
|
7
|
+
<p><%= f.label :password %><br />
|
8
|
+
<%= f.password_field :password %></p>
|
9
9
|
|
10
|
-
<p><%= f.label :password_confirmation
|
11
|
-
|
10
|
+
<p><%= f.label :password_confirmation %><br />
|
11
|
+
<%= f.password_field :password_confirmation %></p>
|
12
12
|
|
13
13
|
<p><%= f.submit "Change my password" %></p>
|
14
14
|
<% end %>
|
@@ -3,8 +3,8 @@
|
|
3
3
|
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name)) do |f| %>
|
4
4
|
<%= devise_error_messages! %>
|
5
5
|
|
6
|
-
<p><%= f.label :email
|
7
|
-
|
6
|
+
<p><%= f.label :email %><br />
|
7
|
+
<%= f.text_field :email %></p>
|
8
8
|
|
9
9
|
<p><%= f.submit "Send me reset password instructions" %></p>
|
10
10
|
<% end %>
|
@@ -3,17 +3,17 @@
|
|
3
3
|
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
|
4
4
|
<%= devise_error_messages! %>
|
5
5
|
|
6
|
-
<p><%= f.label :email
|
7
|
-
|
6
|
+
<p><%= f.label :email %><br />
|
7
|
+
<%= f.text_field :email %></p>
|
8
8
|
|
9
|
-
<p><%= f.label :password %> <i>(leave blank if you don't want to change it)</i
|
10
|
-
|
9
|
+
<p><%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
|
10
|
+
<%= f.password_field :password %></p>
|
11
11
|
|
12
|
-
<p><%= f.label :password_confirmation
|
13
|
-
|
12
|
+
<p><%= f.label :password_confirmation %><br />
|
13
|
+
<%= f.password_field :password_confirmation %></p>
|
14
14
|
|
15
|
-
<p><%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i
|
16
|
-
|
15
|
+
<p><%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
|
16
|
+
<%= f.password_field :current_password %></p>
|
17
17
|
|
18
18
|
<p><%= f.submit "Update" %></p>
|
19
19
|
<% end %>
|
@@ -3,14 +3,14 @@
|
|
3
3
|
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
|
4
4
|
<%= devise_error_messages! %>
|
5
5
|
|
6
|
-
<p><%= f.label :email
|
7
|
-
|
6
|
+
<p><%= f.label :email %><br />
|
7
|
+
<%= f.text_field :email %></p>
|
8
8
|
|
9
|
-
<p><%= f.label :password
|
10
|
-
|
9
|
+
<p><%= f.label :password %><br />
|
10
|
+
<%= f.password_field :password %></p>
|
11
11
|
|
12
|
-
<p><%= f.label :password_confirmation
|
13
|
-
|
12
|
+
<p><%= f.label :password_confirmation %><br />
|
13
|
+
<%= f.password_field :password_confirmation %></p>
|
14
14
|
|
15
15
|
<p><%= f.submit "Sign up" %></p>
|
16
16
|
<% end %>
|
@@ -1,11 +1,11 @@
|
|
1
1
|
<h2>Sign in</h2>
|
2
2
|
|
3
3
|
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
|
4
|
-
<p><%= f.label :email
|
5
|
-
|
4
|
+
<p><%= f.label :email %><br />
|
5
|
+
<%= f.text_field :email %></p>
|
6
6
|
|
7
|
-
<p><%= f.label :password
|
8
|
-
|
7
|
+
<p><%= f.label :password %><br />
|
8
|
+
<%= f.password_field :password %></p>
|
9
9
|
|
10
10
|
<% if devise_mapping.rememberable? -%>
|
11
11
|
<p><%= f.check_box :remember_me %> <%= f.label :remember_me %></p>
|
@@ -3,8 +3,8 @@
|
|
3
3
|
<%= form_for(resource, :as => resource_name, :url => unlock_path(resource_name)) do |f| %>
|
4
4
|
<%= devise_error_messages! %>
|
5
5
|
|
6
|
-
<p><%= f.label :email
|
7
|
-
|
6
|
+
<p><%= f.label :email %><br />
|
7
|
+
<%= f.text_field :email %></p>
|
8
8
|
|
9
9
|
<p><%= f.submit "Resend unlock instructions" %></p>
|
10
10
|
<% end %>
|
data/config/locales/en.yml
CHANGED
@@ -24,13 +24,16 @@ en:
|
|
24
24
|
send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
|
25
25
|
confirmed: 'Your account was successfully confirmed. You are now signed in.'
|
26
26
|
registrations:
|
27
|
-
signed_up: 'You have signed up successfully. If enabled, a confirmation was sent your e-mail.'
|
27
|
+
signed_up: 'You have signed up successfully. If enabled, a confirmation was sent to your e-mail.'
|
28
28
|
updated: 'You updated your account successfully.'
|
29
29
|
destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
|
30
30
|
unlocks:
|
31
31
|
send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
|
32
32
|
unlocked: 'Your account was successfully unlocked. You are now signed in.'
|
33
33
|
mailer:
|
34
|
-
confirmation_instructions:
|
35
|
-
|
36
|
-
|
34
|
+
confirmation_instructions:
|
35
|
+
subject: 'Confirmation instructions'
|
36
|
+
reset_password_instructions:
|
37
|
+
subject: 'Reset password instructions'
|
38
|
+
unlock_instructions:
|
39
|
+
subject: 'Unlock Instructions'
|
data/lib/devise.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'active_support/core_ext/numeric/time'
|
2
|
+
require 'active_support/dependencies'
|
2
3
|
|
3
4
|
module Devise
|
4
5
|
autoload :FailureApp, 'devise/failure_app'
|
6
|
+
autoload :PathChecker, 'devise/path_checker'
|
5
7
|
autoload :Schema, 'devise/schema'
|
6
8
|
autoload :TestHelpers, 'devise/test_helpers'
|
7
9
|
|
@@ -47,6 +49,10 @@ module Devise
|
|
47
49
|
:bcrypt => 60
|
48
50
|
}
|
49
51
|
|
52
|
+
# Custom domain for cookies. Not set by default
|
53
|
+
mattr_accessor :cookie_domain
|
54
|
+
@@cookie_domain = false
|
55
|
+
|
50
56
|
# Used to encrypt password. Please generate one with rake secret.
|
51
57
|
mattr_accessor :pepper
|
52
58
|
@@pepper = nil
|
@@ -93,7 +99,7 @@ module Devise
|
|
93
99
|
|
94
100
|
# Used to define the password encryption algorithm.
|
95
101
|
mattr_accessor :encryptor
|
96
|
-
@@encryptor =
|
102
|
+
@@encryptor = nil
|
97
103
|
|
98
104
|
# Store scopes mappings.
|
99
105
|
mattr_accessor :mappings
|
@@ -143,6 +149,9 @@ module Devise
|
|
143
149
|
mattr_accessor :token_authentication_key
|
144
150
|
@@token_authentication_key = :auth_token
|
145
151
|
|
152
|
+
mattr_accessor :navigational_formats
|
153
|
+
@@navigational_formats = [:html]
|
154
|
+
|
146
155
|
# Private methods to interface with Warden.
|
147
156
|
mattr_accessor :warden_config
|
148
157
|
@@warden_config = nil
|
@@ -154,16 +163,24 @@ module Devise
|
|
154
163
|
yield self
|
155
164
|
end
|
156
165
|
|
166
|
+
# Get the mailer class from the mailer reference object.
|
167
|
+
def self.mailer
|
168
|
+
@@mailer_ref.get
|
169
|
+
end
|
170
|
+
|
171
|
+
# Set the mailer reference object to access the mailer.
|
172
|
+
def self.mailer=(class_name)
|
173
|
+
@@mailer_ref = ActiveSupport::Dependencies.ref(class_name)
|
174
|
+
end
|
175
|
+
self.mailer = "Devise::Mailer"
|
176
|
+
|
157
177
|
# Register a model in Devise. You can call this manually if you don't want
|
158
178
|
# to use devise routes. Check devise_for in routes to know which options
|
159
179
|
# are available.
|
160
|
-
def self.
|
180
|
+
def self.add_model(resource, options)
|
161
181
|
mapping = Devise::Mapping.new(resource, options)
|
162
182
|
self.mappings[mapping.name] = mapping
|
163
183
|
self.default_scope ||= mapping.name
|
164
|
-
|
165
|
-
warden_config.default_scope ||= mapping.name
|
166
|
-
warden_config.scope_defaults mapping.name, :strategies => mapping.strategies
|
167
184
|
mapping
|
168
185
|
end
|
169
186
|
|
@@ -233,7 +250,17 @@ module Devise
|
|
233
250
|
# A method used internally to setup warden manager from the Rails initialize
|
234
251
|
# block.
|
235
252
|
def self.configure_warden! #:nodoc:
|
236
|
-
@@
|
253
|
+
@@warden_configured ||= begin
|
254
|
+
warden_config.failure_app = Devise::FailureApp
|
255
|
+
warden_config.default_scope = Devise.default_scope
|
256
|
+
|
257
|
+
Devise.mappings.each_value do |mapping|
|
258
|
+
warden_config.scope_defaults mapping.name, :strategies => mapping.strategies
|
259
|
+
end
|
260
|
+
|
261
|
+
@@warden_config_block.try :call, Devise.warden_config
|
262
|
+
true
|
263
|
+
end
|
237
264
|
end
|
238
265
|
|
239
266
|
# Generate a friendly string randomically to be used as token.
|
@@ -5,8 +5,8 @@ module Devise
|
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
|
7
7
|
included do
|
8
|
-
helper_method :warden, :signed_in?, :devise_controller?,
|
9
|
-
*Devise.mappings.keys.map { |m| [:"current_#{m}", :"#{m}_signed_in?"] }.flatten
|
8
|
+
helper_method :warden, :signed_in?, :devise_controller?, :anybody_signed_in?,
|
9
|
+
*Devise.mappings.keys.map { |m| [:"current_#{m}", :"#{m}_signed_in?", :"#{m}_session"] }.flatten
|
10
10
|
end
|
11
11
|
|
12
12
|
# The main accessor for the warden proxy instance
|
@@ -29,6 +29,12 @@ module Devise
|
|
29
29
|
warden.authenticate?(:scope => scope)
|
30
30
|
end
|
31
31
|
|
32
|
+
# Check if the any scope is signed in session, without running
|
33
|
+
# authentication hooks.
|
34
|
+
def anybody_signed_in?
|
35
|
+
Devise.mappings.keys.any? { |scope| signed_in?(scope) }
|
36
|
+
end
|
37
|
+
|
32
38
|
# Sign in an user that already was authenticated. This helper is useful for logging
|
33
39
|
# users in after sign up.
|
34
40
|
#
|
@@ -102,6 +108,36 @@ module Devise
|
|
102
108
|
respond_to?(home_path, true) ? send(home_path) : root_path
|
103
109
|
end
|
104
110
|
|
111
|
+
# The default url to be used after updating a resource. This is used by all Devise
|
112
|
+
# controllers and you can overwrite it in your ApplicationController to
|
113
|
+
# provide a custom hook for a custom resource.
|
114
|
+
#
|
115
|
+
# By default, it first tries to find a resource_root_path, otherwise it
|
116
|
+
# uses the root path. For a user scope, you can define the default url in
|
117
|
+
# the following way:
|
118
|
+
#
|
119
|
+
# map.user_root '/users', :controller => 'users' # creates user_root_path
|
120
|
+
#
|
121
|
+
# map.resources :users do |users|
|
122
|
+
# users.root # creates user_root_path
|
123
|
+
# end
|
124
|
+
#
|
125
|
+
#
|
126
|
+
# If none of these are defined, root_path is used. However, if this default
|
127
|
+
# is not enough, you can customize it, for example:
|
128
|
+
#
|
129
|
+
# def after_update_path_for(resource)
|
130
|
+
# if resource.is_a?(User) && resource.can_publish?
|
131
|
+
# publisher_url
|
132
|
+
# else
|
133
|
+
# super
|
134
|
+
# end
|
135
|
+
# end
|
136
|
+
#
|
137
|
+
def after_update_path_for(resource_or_scope)
|
138
|
+
after_sign_in_path_for(resource_or_scope)
|
139
|
+
end
|
140
|
+
|
105
141
|
# Method used by sessions controller to sign out an user. You can overwrite
|
106
142
|
# it in your ApplicationController to provide a custom hook for a custom
|
107
143
|
# scope. Notice that differently from +after_sign_in_path_for+ this method
|
@@ -7,7 +7,6 @@ module Devise
|
|
7
7
|
# Warning: it uses Devise's stretches configuration to port Authlogic's one. Should be set to 20 in the initializer to silumate
|
8
8
|
# the default behavior.
|
9
9
|
class AuthlogicSha512 < Base
|
10
|
-
|
11
10
|
# Gererates a default password digest based on salt, pepper and the
|
12
11
|
# incoming password.
|
13
12
|
def self.digest(password, stretches, salt, pepper)
|
@@ -15,7 +14,6 @@ module Devise
|
|
15
14
|
stretches.times { digest = Digest::SHA512.hexdigest(digest) }
|
16
15
|
digest
|
17
16
|
end
|
18
|
-
|
19
17
|
end
|
20
18
|
end
|
21
19
|
end
|
@@ -5,7 +5,6 @@ module Devise
|
|
5
5
|
# = BCrypt
|
6
6
|
# Uses the BCrypt hash algorithm to encrypt passwords.
|
7
7
|
class Bcrypt < Base
|
8
|
-
|
9
8
|
# Gererates a default password digest based on stretches, salt, pepper and the
|
10
9
|
# incoming password. We don't strech it ourselves since BCrypt does so internally.
|
11
10
|
def self.digest(password, stretches, salt, pepper)
|
@@ -15,7 +14,6 @@ module Devise
|
|
15
14
|
def self.salt
|
16
15
|
::BCrypt::Engine.generate_salt
|
17
16
|
end
|
18
|
-
|
19
17
|
end
|
20
18
|
end
|
21
19
|
end
|
@@ -7,13 +7,11 @@ module Devise
|
|
7
7
|
# Warning: it uses Devise's pepper to port the concept of REST_AUTH_SITE_KEY
|
8
8
|
# Warning: it uses Devise's stretches configuration to port the concept of REST_AUTH_DIGEST_STRETCHES
|
9
9
|
class ClearanceSha1 < Base
|
10
|
-
|
11
10
|
# Gererates a default password digest based on salt, pepper and the
|
12
11
|
# incoming password.
|
13
12
|
def self.digest(password, stretches, salt, pepper)
|
14
13
|
Digest::SHA1.hexdigest("--#{salt}--#{password}--")
|
15
14
|
end
|
16
|
-
|
17
15
|
end
|
18
16
|
end
|
19
17
|
end
|
@@ -5,7 +5,6 @@ module Devise
|
|
5
5
|
# = Sha1
|
6
6
|
# Uses the Sha1 hash algorithm to encrypt passwords.
|
7
7
|
class Sha1 < Base
|
8
|
-
|
9
8
|
# Gererates a default password digest based on stretches, salt, pepper and the
|
10
9
|
# incoming password.
|
11
10
|
def self.digest(password, stretches, salt, pepper)
|
@@ -14,14 +13,13 @@ module Devise
|
|
14
13
|
digest
|
15
14
|
end
|
16
15
|
|
17
|
-
|
16
|
+
private
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
18
|
+
# Generate a SHA1 digest joining args. Generated token is something like
|
19
|
+
# --arg1--arg2--arg3--argN--
|
20
|
+
def self.secure_digest(*tokens)
|
21
|
+
::Digest::SHA1.hexdigest('--' << tokens.flatten.join('--') << '--')
|
22
|
+
end
|
25
23
|
end
|
26
24
|
end
|
27
25
|
end
|
@@ -5,7 +5,6 @@ module Devise
|
|
5
5
|
# = Sha512
|
6
6
|
# Uses the Sha512 hash algorithm to encrypt passwords.
|
7
7
|
class Sha512 < Base
|
8
|
-
|
9
8
|
# Gererates a default password digest based on salt, pepper and the
|
10
9
|
# incoming password.
|
11
10
|
def self.digest(password, stretches, salt, pepper)
|
@@ -14,14 +13,13 @@ module Devise
|
|
14
13
|
digest
|
15
14
|
end
|
16
15
|
|
17
|
-
|
16
|
+
private
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
18
|
+
# Generate a Sha512 digest joining args. Generated token is something like
|
19
|
+
# --arg1--arg2--arg3--argN--
|
20
|
+
def self.secure_digest(*tokens)
|
21
|
+
::Digest::SHA512.hexdigest('--' << tokens.flatten.join('--') << '--')
|
22
|
+
end
|
25
23
|
end
|
26
24
|
end
|
27
25
|
end
|
data/lib/devise/failure_app.rb
CHANGED
@@ -9,6 +9,7 @@ module Devise
|
|
9
9
|
include ActionController::RackDelegation
|
10
10
|
include ActionController::UrlFor
|
11
11
|
include ActionController::Redirecting
|
12
|
+
include Rails.application.routes.url_helpers
|
12
13
|
|
13
14
|
delegate :flash, :to => :request
|
14
15
|
|
@@ -63,7 +64,7 @@ module Devise
|
|
63
64
|
end
|
64
65
|
|
65
66
|
def http_auth?
|
66
|
-
request.
|
67
|
+
!Devise.navigational_formats.include?(request.format.to_sym) || request.xhr?
|
67
68
|
end
|
68
69
|
|
69
70
|
def http_auth_body
|
@@ -96,7 +97,7 @@ module Devise
|
|
96
97
|
# yet, but we still need to store the uri based on scope, so different scopes
|
97
98
|
# would never use the same uri to redirect.
|
98
99
|
def store_location!
|
99
|
-
session[:"#{scope}_return_to"] = attempted_path if request &&
|
100
|
+
session[:"#{scope}_return_to"] = attempted_path if request.get? && !http_auth?
|
100
101
|
end
|
101
102
|
end
|
102
103
|
end
|
@@ -1,4 +1,7 @@
|
|
1
|
-
# Deny user access whenever his account is not active yet.
|
1
|
+
# Deny user access whenever his account is not active yet. All strategies that inherits from
|
2
|
+
# Devise::Strategies::Authenticatable and uses the validate already check if the user is active?
|
3
|
+
# before actively signing him in. However, we need this as hook to validate the user activity
|
4
|
+
# in each request and in case the user is using other strategies beside Devise ones.
|
2
5
|
Warden::Manager.after_set_user do |record, warden, options|
|
3
6
|
if record && record.respond_to?(:active?) && !record.active?
|
4
7
|
scope = options[:scope]
|
@@ -2,9 +2,10 @@
|
|
2
2
|
# to forget_me! Also clear remember token to ensure the user won't be
|
3
3
|
# remembered again. Notice that we forget the user unless the record is frozen.
|
4
4
|
# This avoids forgetting deleted users.
|
5
|
-
Warden::Manager.before_logout do |record, warden,
|
5
|
+
Warden::Manager.before_logout do |record, warden, options|
|
6
6
|
if record.respond_to?(:forget_me!)
|
7
7
|
record.forget_me! unless record.frozen?
|
8
|
-
|
8
|
+
options = record.cookie_domain? ? { :domain => record.cookie_domain } : {}
|
9
|
+
warden.cookies.delete("remember_#{options[:scope]}_token", options)
|
9
10
|
end
|
10
|
-
end
|
11
|
+
end
|
@@ -11,11 +11,14 @@ module Devise
|
|
11
11
|
if succeeded? && resource.respond_to?(:remember_me!) && remember_me?
|
12
12
|
resource.remember_me!
|
13
13
|
|
14
|
-
|
14
|
+
configuration = {
|
15
15
|
:value => resource.class.serialize_into_cookie(resource),
|
16
16
|
:expires => resource.remember_expires_at,
|
17
17
|
:path => "/"
|
18
18
|
}
|
19
|
+
|
20
|
+
configuration[:domain] = resource.cookie_domain if resource.cookie_domain?
|
21
|
+
cookies.signed["remember_#{scope}_token"] = configuration
|
19
22
|
end
|
20
23
|
end
|
21
24
|
|
@@ -28,4 +31,5 @@ module Devise
|
|
28
31
|
end
|
29
32
|
end
|
30
33
|
|
31
|
-
Devise::Strategies::Authenticatable.send :include, Devise::Hooks::Rememberable
|
34
|
+
Devise::Strategies::Authenticatable.send :include, Devise::Hooks::Rememberable
|
35
|
+
|