devise 2.1.4 → 2.2.0.rc
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/.travis.yml +26 -0
- data/CHANGELOG.rdoc +29 -10
- data/CONTRIBUTING.md +14 -0
- data/Gemfile +2 -8
- data/Gemfile.lock +68 -77
- data/README.md +15 -9
- data/app/controllers/devise/omniauth_callbacks_controller.rb +1 -1
- data/app/controllers/devise/passwords_controller.rb +9 -0
- data/app/controllers/devise/registrations_controller.rb +17 -5
- data/app/controllers/devise/sessions_controller.rb +3 -3
- data/app/controllers/devise_controller.rb +3 -11
- data/app/views/devise/confirmations/new.html.erb +1 -1
- data/app/views/devise/mailer/confirmation_instructions.html.erb +1 -1
- data/app/views/devise/mailer/unlock_instructions.html.erb +1 -1
- data/app/views/devise/passwords/edit.html.erb +1 -1
- data/app/views/devise/passwords/new.html.erb +1 -1
- data/app/views/devise/registrations/edit.html.erb +5 -1
- data/app/views/devise/registrations/new.html.erb +1 -1
- data/app/views/devise/sessions/new.html.erb +1 -1
- data/app/views/devise/unlocks/new.html.erb +1 -1
- data/config/locales/en.yml +2 -0
- data/gemfiles/Gemfile.rails-3.1.x +1 -3
- data/gemfiles/Gemfile.rails-3.1.x.lock +9 -12
- data/lib/devise.rb +12 -7
- data/lib/devise/controllers/helpers.rb +16 -3
- data/lib/devise/mailers/helpers.rb +14 -8
- data/lib/devise/models/authenticatable.rb +14 -9
- data/lib/devise/models/confirmable.rb +36 -3
- data/lib/devise/models/database_authenticatable.rb +2 -1
- data/lib/devise/models/lockable.rb +6 -2
- data/lib/devise/models/recoverable.rb +2 -2
- data/lib/devise/models/token_authenticatable.rb +12 -0
- data/lib/devise/models/trackable.rb +1 -1
- data/lib/devise/models/validatable.rb +1 -1
- data/lib/devise/param_filter.rb +2 -1
- data/lib/devise/rails/routes.rb +11 -11
- data/lib/devise/strategies/database_authenticatable.rb +1 -1
- data/lib/devise/test_helpers.rb +3 -2
- data/lib/devise/time_inflector.rb +14 -0
- data/lib/devise/version.rb +1 -1
- data/lib/generators/active_record/devise_generator.rb +5 -1
- data/lib/generators/mongoid/devise_generator.rb +0 -3
- data/lib/generators/templates/README +5 -1
- data/lib/generators/templates/devise.rb +12 -4
- data/lib/generators/templates/markerb/confirmation_instructions.markerb +1 -1
- data/lib/generators/templates/markerb/unlock_instructions.markerb +1 -1
- data/lib/generators/templates/simple_form_for/confirmations/new.html.erb +2 -1
- data/lib/generators/templates/simple_form_for/passwords/edit.html.erb +1 -1
- data/lib/generators/templates/simple_form_for/passwords/new.html.erb +1 -1
- data/lib/generators/templates/simple_form_for/registrations/edit.html.erb +5 -0
- data/lib/generators/templates/simple_form_for/unlocks/new.html.erb +2 -1
- data/test/controllers/internal_helpers_test.rb +6 -0
- data/test/controllers/sessions_controller_test.rb +43 -1
- data/test/devise_test.rb +12 -1
- data/test/generators/active_record_generator_test.rb +7 -1
- data/test/integration/authenticatable_test.rb +4 -4
- data/test/integration/confirmable_test.rb +44 -0
- data/test/integration/database_authenticatable_test.rb +17 -15
- data/test/integration/http_authenticatable_test.rb +3 -3
- data/test/integration/lockable_test.rb +18 -0
- data/test/integration/omniauthable_test.rb +2 -2
- data/test/integration/recoverable_test.rb +43 -6
- data/test/integration/registerable_test.rb +34 -11
- data/test/mailers/confirmation_instructions_test.rb +7 -0
- data/test/models/authenticatable_test.rb +1 -7
- data/test/models/confirmable_test.rb +35 -1
- data/test/models/database_authenticatable_test.rb +49 -24
- data/test/models/lockable_test.rb +13 -3
- data/test/models/serializable_test.rb +2 -1
- data/test/models_test.rb +1 -22
- data/test/orm/mongoid.rb +2 -3
- data/test/rails_app/app/controllers/application_controller.rb +1 -0
- data/test/rails_app/app/mailers/users/mailer.rb +6 -1
- data/test/rails_app/app/mongoid/admin.rb +4 -2
- data/test/rails_app/app/mongoid/shim.rb +3 -3
- data/test/rails_app/app/mongoid/user.rb +2 -2
- data/test/rails_app/config/initializers/devise.rb +2 -2
- data/test/rails_app/lib/shared_user.rb +1 -1
- data/test/support/helpers.rb +2 -2
- data/test/support/integration.rb +4 -3
- data/test/test_helpers_test.rb +19 -2
- data/test/test_models.rb +27 -0
- metadata +31 -29
- data/test/indifferent_hash.rb +0 -33
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'test_helper'
|
2
|
+
require 'test_models'
|
2
3
|
require 'digest/sha1'
|
3
4
|
|
4
5
|
class DatabaseAuthenticatableTest < ActiveSupport::TestCase
|
@@ -12,6 +13,17 @@ class DatabaseAuthenticatableTest < ActiveSupport::TestCase
|
|
12
13
|
assert_equal email.downcase, user.email
|
13
14
|
end
|
14
15
|
|
16
|
+
test 'should downcase case insensitive keys that refer to virtual attributes when saving' do
|
17
|
+
email = 'Foo@Bar1.com'
|
18
|
+
confirmation = 'Foo@Bar1.com'
|
19
|
+
attributes = valid_attributes(:email => email, :email_confirmation => confirmation)
|
20
|
+
user = UserWithVirtualAttributes.new(attributes)
|
21
|
+
|
22
|
+
assert_equal confirmation, user.email_confirmation
|
23
|
+
user.save!
|
24
|
+
assert_equal confirmation.downcase, user.email_confirmation
|
25
|
+
end
|
26
|
+
|
15
27
|
test 'should remove whitespace from strip whitespace keys when saving' do
|
16
28
|
# strip_whitespace_keys is set to :email by default.
|
17
29
|
email = ' foo@bar.com '
|
@@ -23,9 +35,15 @@ class DatabaseAuthenticatableTest < ActiveSupport::TestCase
|
|
23
35
|
end
|
24
36
|
|
25
37
|
test "param filter should not convert booleans and integer to strings" do
|
26
|
-
conditions = {
|
38
|
+
conditions = { 'login' => 'foo@bar.com', "bool1" => true, "bool2" => false, "fixnum" => 123, "will_be_converted" => (1..10) }
|
27
39
|
conditions = Devise::ParamFilter.new([], []).filter(conditions)
|
28
|
-
assert_equal( {
|
40
|
+
assert_equal( { 'login' => 'foo@bar.com', "bool1" => true, "bool2" => false, "fixnum" => 123, "will_be_converted" => "1..10" }, conditions)
|
41
|
+
end
|
42
|
+
|
43
|
+
test "param filter should not convert regular expressions to strings" do
|
44
|
+
conditions = { "regexp" => /expression/ }
|
45
|
+
conditions = Devise::ParamFilter.new([], []).filter(conditions)
|
46
|
+
assert_equal( { "regexp" => /expression/ }, conditions)
|
29
47
|
end
|
30
48
|
|
31
49
|
test 'should respond to password and password confirmation' do
|
@@ -60,14 +78,14 @@ class DatabaseAuthenticatableTest < ActiveSupport::TestCase
|
|
60
78
|
|
61
79
|
test 'should test for a valid password' do
|
62
80
|
user = create_user
|
63
|
-
assert user.valid_password?('
|
81
|
+
assert user.valid_password?('12345678')
|
64
82
|
assert_not user.valid_password?('654321')
|
65
83
|
end
|
66
84
|
|
67
85
|
test 'should not raise error with an empty password' do
|
68
86
|
user = create_user
|
69
87
|
user.encrypted_password = ''
|
70
|
-
assert_nothing_raised { user.valid_password?('
|
88
|
+
assert_nothing_raised { user.valid_password?('12345678') }
|
71
89
|
end
|
72
90
|
|
73
91
|
test 'should be an invalid password if the user has an empty password' do
|
@@ -82,31 +100,38 @@ class DatabaseAuthenticatableTest < ActiveSupport::TestCase
|
|
82
100
|
|
83
101
|
test 'should update password with valid current password' do
|
84
102
|
user = create_user
|
85
|
-
assert user.update_with_password(:current_password => '
|
86
|
-
:password => '
|
87
|
-
assert user.reload.valid_password?('
|
103
|
+
assert user.update_with_password(:current_password => '12345678',
|
104
|
+
:password => 'pass4321', :password_confirmation => 'pass4321')
|
105
|
+
assert user.reload.valid_password?('pass4321')
|
88
106
|
end
|
89
107
|
|
90
108
|
test 'should update password with valid current password and :as option' do
|
91
109
|
user = create_user
|
92
|
-
assert user.update_with_password(:current_password => '
|
93
|
-
:password => '
|
94
|
-
assert user.reload.valid_password?('
|
110
|
+
assert user.update_with_password(:current_password => '12345678',
|
111
|
+
:password => 'pass4321', :password_confirmation => 'pass4321', :as => :admin)
|
112
|
+
assert user.reload.valid_password?('pass4321')
|
95
113
|
end
|
96
114
|
|
97
115
|
test 'should add an error to current password when it is invalid' do
|
98
116
|
user = create_user
|
99
117
|
assert_not user.update_with_password(:current_password => 'other',
|
100
|
-
:password => '
|
101
|
-
assert user.reload.valid_password?('
|
118
|
+
:password => 'pass4321', :password_confirmation => 'pass4321')
|
119
|
+
assert user.reload.valid_password?('12345678')
|
102
120
|
assert_match "is invalid", user.errors[:current_password].join
|
103
121
|
end
|
104
122
|
|
123
|
+
test 'should not change encrypted password when it is invalid' do
|
124
|
+
user = create_user
|
125
|
+
assert_not user.update_with_password(:current_password => 'other',
|
126
|
+
:password => 'pass4321', :password_confirmation => 'pass4321')
|
127
|
+
assert_not user.encrypted_password_changed?
|
128
|
+
end
|
129
|
+
|
105
130
|
test 'should add an error to current password when it is blank' do
|
106
131
|
user = create_user
|
107
|
-
assert_not user.update_with_password(:password => '
|
108
|
-
:password_confirmation => '
|
109
|
-
assert user.reload.valid_password?('
|
132
|
+
assert_not user.update_with_password(:password => 'pass4321',
|
133
|
+
:password_confirmation => 'pass4321')
|
134
|
+
assert user.reload.valid_password?('12345678')
|
110
135
|
assert_match "can't be blank", user.errors[:current_password].join
|
111
136
|
end
|
112
137
|
|
@@ -121,21 +146,21 @@ class DatabaseAuthenticatableTest < ActiveSupport::TestCase
|
|
121
146
|
|
122
147
|
test 'should ignore password and its confirmation if they are blank' do
|
123
148
|
user = create_user
|
124
|
-
assert user.update_with_password(:current_password => '
|
149
|
+
assert user.update_with_password(:current_password => '12345678', :email => "new@example.com")
|
125
150
|
assert_equal "new@example.com", user.email
|
126
151
|
end
|
127
152
|
|
128
153
|
test 'should not update password with invalid confirmation' do
|
129
154
|
user = create_user
|
130
|
-
assert_not user.update_with_password(:current_password => '
|
131
|
-
:password => '
|
132
|
-
assert user.reload.valid_password?('
|
155
|
+
assert_not user.update_with_password(:current_password => '12345678',
|
156
|
+
:password => 'pass4321', :password_confirmation => 'other')
|
157
|
+
assert user.reload.valid_password?('12345678')
|
133
158
|
end
|
134
159
|
|
135
160
|
test 'should clean up password fields on failure' do
|
136
161
|
user = create_user
|
137
|
-
assert_not user.update_with_password(:current_password => '
|
138
|
-
:password => '
|
162
|
+
assert_not user.update_with_password(:current_password => '12345678',
|
163
|
+
:password => 'pass4321', :password_confirmation => 'other')
|
139
164
|
assert user.password.blank?
|
140
165
|
assert user.password_confirmation.blank?
|
141
166
|
end
|
@@ -154,9 +179,9 @@ class DatabaseAuthenticatableTest < ActiveSupport::TestCase
|
|
154
179
|
|
155
180
|
test 'should not update password without password' do
|
156
181
|
user = create_user
|
157
|
-
user.update_without_password(:password => '
|
158
|
-
assert !user.reload.valid_password?('
|
159
|
-
assert user.valid_password?('
|
182
|
+
user.update_without_password(:password => 'pass4321', :password_confirmation => 'pass4321')
|
183
|
+
assert !user.reload.valid_password?('pass4321')
|
184
|
+
assert user.valid_password?('12345678')
|
160
185
|
end
|
161
186
|
|
162
187
|
test 'downcase_keys with validation' do
|
@@ -232,19 +232,19 @@ class LockableTest < ActiveSupport::TestCase
|
|
232
232
|
swap Devise, :lock_strategy => :failed_attempts do
|
233
233
|
assert_same_content Devise::Models::Lockable.required_fields(User), [
|
234
234
|
:failed_attempts,
|
235
|
-
:
|
235
|
+
:locked_at,
|
236
236
|
:unlock_token
|
237
237
|
]
|
238
238
|
end
|
239
239
|
end
|
240
240
|
end
|
241
241
|
|
242
|
-
test 'required_fields should contain only failed_attempts and
|
242
|
+
test 'required_fields should contain only failed_attempts and locked_at when the strategies are time and failed_attempts are enabled' do
|
243
243
|
swap Devise, :unlock_strategy => :time do
|
244
244
|
swap Devise, :lock_strategy => :failed_attempts do
|
245
245
|
assert_same_content Devise::Models::Lockable.required_fields(User), [
|
246
246
|
:failed_attempts,
|
247
|
-
:
|
247
|
+
:locked_at
|
248
248
|
]
|
249
249
|
end
|
250
250
|
end
|
@@ -260,4 +260,14 @@ class LockableTest < ActiveSupport::TestCase
|
|
260
260
|
end
|
261
261
|
end
|
262
262
|
end
|
263
|
+
|
264
|
+
test 'should not return a locked unauthenticated message if in paranoid mode' do
|
265
|
+
swap Devise, :paranoid => :true do
|
266
|
+
user = create_user
|
267
|
+
user.failed_attempts = Devise.maximum_attempts + 1
|
268
|
+
user.lock_access!
|
269
|
+
|
270
|
+
assert_equal :invalid, user.unauthenticated_message
|
271
|
+
end
|
272
|
+
end
|
263
273
|
end
|
@@ -21,7 +21,8 @@ class SerializableTest < ActiveSupport::TestCase
|
|
21
21
|
end
|
22
22
|
|
23
23
|
test 'should not include unsafe keys on JSON' do
|
24
|
-
|
24
|
+
keys = from_json().keys.select{ |key| !key.include?("id") }
|
25
|
+
assert_equal %w(created_at email facebook_token updated_at username), keys.sort
|
25
26
|
end
|
26
27
|
|
27
28
|
test 'should not include unsafe keys on JSON even if a new except is provided' do
|
data/test/models_test.rb
CHANGED
@@ -1,26 +1,5 @@
|
|
1
1
|
require 'test_helper'
|
2
|
-
|
3
|
-
class Configurable < User
|
4
|
-
devise :database_authenticatable, :confirmable, :rememberable, :timeoutable, :lockable,
|
5
|
-
:stretches => 15, :pepper => 'abcdef', :allow_unconfirmed_access_for => 5.days,
|
6
|
-
:remember_for => 7.days, :timeout_in => 15.minutes, :unlock_in => 10.days
|
7
|
-
end
|
8
|
-
|
9
|
-
class WithValidation < Admin
|
10
|
-
devise :database_authenticatable, :validatable, :password_length => 2..6
|
11
|
-
end
|
12
|
-
|
13
|
-
class UserWithValidation < User
|
14
|
-
validates_presence_of :username
|
15
|
-
end
|
16
|
-
|
17
|
-
class Several < Admin
|
18
|
-
devise :validatable
|
19
|
-
devise :lockable
|
20
|
-
end
|
21
|
-
|
22
|
-
class Inheritable < Admin
|
23
|
-
end
|
2
|
+
require 'test_models'
|
24
3
|
|
25
4
|
class ActiveRecordTest < ActiveSupport::TestCase
|
26
5
|
def include_module?(klass, mod)
|
data/test/orm/mongoid.rb
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
require 'mongoid/version'
|
2
2
|
|
3
3
|
Mongoid.configure do |config|
|
4
|
-
config.
|
4
|
+
config.connect_to("devise-test-suite")
|
5
5
|
config.use_utc = true
|
6
6
|
config.include_root_in_json = true
|
7
7
|
end
|
8
8
|
|
9
9
|
class ActiveSupport::TestCase
|
10
10
|
setup do
|
11
|
-
|
12
|
-
Admin.delete_all
|
11
|
+
Mongoid.purge!
|
13
12
|
end
|
14
13
|
end
|
@@ -1,3 +1,8 @@
|
|
1
1
|
class Users::Mailer < Devise::Mailer
|
2
|
-
default :from
|
2
|
+
default :from => 'custom@example.com'
|
3
3
|
end
|
4
|
+
|
5
|
+
class Users::ReplyToMailer < Devise::Mailer
|
6
|
+
default :from => 'custom@example.com'
|
7
|
+
default :reply_to => 'custom_reply_to@example.com'
|
8
|
+
end
|
@@ -6,8 +6,8 @@ class Admin
|
|
6
6
|
include SharedAdmin
|
7
7
|
|
8
8
|
## Database authenticatable
|
9
|
-
field :email, :type => String
|
10
|
-
field :encrypted_password, :type => String
|
9
|
+
field :email, :type => String
|
10
|
+
field :encrypted_password, :type => String
|
11
11
|
|
12
12
|
## Recoverable
|
13
13
|
field :reset_password_token, :type => String
|
@@ -24,4 +24,6 @@ class Admin
|
|
24
24
|
|
25
25
|
## Lockable
|
26
26
|
field :locked_at, :type => Time
|
27
|
+
|
28
|
+
field :active, :type => Boolean, :default => false
|
27
29
|
end
|
@@ -7,13 +7,13 @@ module Shim
|
|
7
7
|
end
|
8
8
|
|
9
9
|
module ClassMethods
|
10
|
-
def last(options={})
|
10
|
+
def last(options = {})
|
11
11
|
options.delete(:order) if options[:order] == "id"
|
12
|
-
|
12
|
+
where(options).last
|
13
13
|
end
|
14
14
|
|
15
15
|
def find_by_email(email)
|
16
|
-
|
16
|
+
find_by(:email => email)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -9,8 +9,8 @@ class User
|
|
9
9
|
field :facebook_token, :type => String
|
10
10
|
|
11
11
|
## Database authenticatable
|
12
|
-
field :email, :type => String, :
|
13
|
-
field :encrypted_password, :type => String, :
|
12
|
+
field :email, :type => String, :default => ""
|
13
|
+
field :encrypted_password, :type => String, :default => ""
|
14
14
|
|
15
15
|
## Recoverable
|
16
16
|
field :reset_password_token, :type => String
|
@@ -85,8 +85,8 @@ Devise.setup do |config|
|
|
85
85
|
# config.extend_remember_period = false
|
86
86
|
|
87
87
|
# ==> Configuration for :validatable
|
88
|
-
# Range for password length. Default is
|
89
|
-
# config.password_length =
|
88
|
+
# Range for password length. Default is 8..128.
|
89
|
+
# config.password_length = 8..128
|
90
90
|
|
91
91
|
# Regex to use to validate the email address
|
92
92
|
# config.email_regexp = /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i
|
@@ -7,7 +7,7 @@ module SharedUser
|
|
7
7
|
:trackable, :validatable, :omniauthable
|
8
8
|
|
9
9
|
attr_accessor :other_key
|
10
|
-
attr_accessible :username, :email, :password, :password_confirmation, :remember_me
|
10
|
+
attr_accessible :username, :email, :password, :password_confirmation, :remember_me, :confirmation_sent_at
|
11
11
|
|
12
12
|
# They need to be included after Devise is called.
|
13
13
|
extend ExtendMethods
|
data/test/support/helpers.rb
CHANGED
@@ -25,8 +25,8 @@ class ActiveSupport::TestCase
|
|
25
25
|
def valid_attributes(attributes={})
|
26
26
|
{ :username => "usertest",
|
27
27
|
:email => generate_unique_email,
|
28
|
-
:password => '
|
29
|
-
:password_confirmation => '
|
28
|
+
:password => '12345678',
|
29
|
+
:password_confirmation => '12345678' }.update(attributes)
|
30
30
|
end
|
31
31
|
|
32
32
|
def new_user(attributes={})
|
data/test/support/integration.rb
CHANGED
@@ -10,10 +10,11 @@ class ActionDispatch::IntegrationTest
|
|
10
10
|
user = User.create!(
|
11
11
|
:username => 'usertest',
|
12
12
|
:email => options[:email] || 'user@test.com',
|
13
|
-
:password => options[:password] || '
|
14
|
-
:password_confirmation => options[:password] || '
|
13
|
+
:password => options[:password] || '12345678',
|
14
|
+
:password_confirmation => options[:password] || '12345678',
|
15
15
|
:created_at => Time.now.utc
|
16
16
|
)
|
17
|
+
user.update_attribute(:confirmation_sent_at, options[:confirmation_sent_at]) if options[:confirmation_sent_at]
|
17
18
|
user.confirm! unless options[:confirm] == false
|
18
19
|
user.lock_access! if options[:locked] == true
|
19
20
|
user
|
@@ -36,7 +37,7 @@ class ActionDispatch::IntegrationTest
|
|
36
37
|
user = create_user(options)
|
37
38
|
visit_with_option options[:visit], new_user_session_path
|
38
39
|
fill_in 'email', :with => options[:email] || 'user@test.com'
|
39
|
-
fill_in 'password', :with => options[:password] || '
|
40
|
+
fill_in 'password', :with => options[:password] || '12345678'
|
40
41
|
check 'remember me' if options[:remember_me] == true
|
41
42
|
yield if block_given?
|
42
43
|
click_button 'Sign In'
|
data/test/test_helpers_test.rb
CHANGED
@@ -9,7 +9,7 @@ class TestHelpersTest < ActionController::TestCase
|
|
9
9
|
self.status = 306
|
10
10
|
end
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
test "redirects if attempting to access a page unauthenticated" do
|
14
14
|
get :index
|
15
15
|
assert_redirected_to new_user_session_path
|
@@ -47,6 +47,18 @@ class TestHelpersTest < ActionController::TestCase
|
|
47
47
|
assert_response :success
|
48
48
|
end
|
49
49
|
|
50
|
+
test "does not redirect with valid user after failed first attempt" do
|
51
|
+
get :index
|
52
|
+
assert_response :redirect
|
53
|
+
|
54
|
+
user = create_user
|
55
|
+
user.confirm!
|
56
|
+
|
57
|
+
sign_in user
|
58
|
+
get :index
|
59
|
+
assert_response :success
|
60
|
+
end
|
61
|
+
|
50
62
|
test "redirects if valid user signed out" do
|
51
63
|
user = create_user
|
52
64
|
user.confirm!
|
@@ -58,7 +70,7 @@ class TestHelpersTest < ActionController::TestCase
|
|
58
70
|
get :index
|
59
71
|
assert_redirected_to new_user_session_path
|
60
72
|
end
|
61
|
-
|
73
|
+
|
62
74
|
test "respects custom failure app" do
|
63
75
|
begin
|
64
76
|
Devise.warden_config.failure_app = CustomFailureApp
|
@@ -69,6 +81,11 @@ class TestHelpersTest < ActionController::TestCase
|
|
69
81
|
end
|
70
82
|
end
|
71
83
|
|
84
|
+
test "returns the body of a failure app" do
|
85
|
+
get :index
|
86
|
+
assert_equal response.body, "<html><body>You are being <a href=\"http://test.host/users/sign_in\">redirected</a>.</body></html>"
|
87
|
+
end
|
88
|
+
|
72
89
|
test "defined Warden after_authentication callback should not be called when sign_in is called" do
|
73
90
|
begin
|
74
91
|
Warden::Manager.after_authentication do |user, auth, opts|
|
data/test/test_models.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
class Configurable < User
|
2
|
+
devise :database_authenticatable, :confirmable, :rememberable, :timeoutable, :lockable,
|
3
|
+
:stretches => 15, :pepper => 'abcdef', :allow_unconfirmed_access_for => 5.days,
|
4
|
+
:remember_for => 7.days, :timeout_in => 15.minutes, :unlock_in => 10.days
|
5
|
+
end
|
6
|
+
|
7
|
+
class WithValidation < Admin
|
8
|
+
devise :database_authenticatable, :validatable, :password_length => 2..6
|
9
|
+
end
|
10
|
+
|
11
|
+
class UserWithValidation < User
|
12
|
+
validates_presence_of :username
|
13
|
+
end
|
14
|
+
|
15
|
+
class UserWithVirtualAttributes < User
|
16
|
+
devise :case_insensitive_keys => [ :email, :email_confirmation ]
|
17
|
+
validates :email, :presence => true, :confirmation => {:on => :create}
|
18
|
+
attr_accessible :email, :email_confirmation
|
19
|
+
end
|
20
|
+
|
21
|
+
class Several < Admin
|
22
|
+
devise :validatable
|
23
|
+
devise :lockable
|
24
|
+
end
|
25
|
+
|
26
|
+
class Inheritable < Admin
|
27
|
+
end
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
4
|
+
prerelease: 6
|
5
|
+
version: 2.2.0.rc
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- José Valim
|
@@ -10,72 +10,72 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2012-12-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
|
17
|
-
requirement: !ruby/object:Gem::Requirement
|
18
|
-
none: false
|
16
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
17
|
requirements:
|
20
18
|
- - ~>
|
21
19
|
- !ruby/object:Gem::Version
|
22
20
|
version: 1.2.1
|
21
|
+
none: false
|
22
|
+
name: warden
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
|
26
|
-
none: false
|
25
|
+
requirement: !ruby/object:Gem::Requirement
|
27
26
|
requirements:
|
28
27
|
- - ~>
|
29
28
|
- !ruby/object:Gem::Version
|
30
29
|
version: 1.2.1
|
31
|
-
- !ruby/object:Gem::Dependency
|
32
|
-
name: orm_adapter
|
33
|
-
requirement: !ruby/object:Gem::Requirement
|
34
30
|
none: false
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
version_requirements: !ruby/object:Gem::Requirement
|
35
33
|
requirements:
|
36
34
|
- - ~>
|
37
35
|
- !ruby/object:Gem::Version
|
38
36
|
version: '0.1'
|
37
|
+
none: false
|
38
|
+
name: orm_adapter
|
39
39
|
type: :runtime
|
40
40
|
prerelease: false
|
41
|
-
|
42
|
-
none: false
|
41
|
+
requirement: !ruby/object:Gem::Requirement
|
43
42
|
requirements:
|
44
43
|
- - ~>
|
45
44
|
- !ruby/object:Gem::Version
|
46
45
|
version: '0.1'
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: bcrypt-ruby
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
46
|
none: false
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
49
|
requirements:
|
52
50
|
- - ~>
|
53
51
|
- !ruby/object:Gem::Version
|
54
52
|
version: '3.0'
|
53
|
+
none: false
|
54
|
+
name: bcrypt-ruby
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
|
58
|
-
none: false
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
59
58
|
requirements:
|
60
59
|
- - ~>
|
61
60
|
- !ruby/object:Gem::Version
|
62
61
|
version: '3.0'
|
63
|
-
- !ruby/object:Gem::Dependency
|
64
|
-
name: railties
|
65
|
-
requirement: !ruby/object:Gem::Requirement
|
66
62
|
none: false
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
65
|
requirements:
|
68
66
|
- - ~>
|
69
67
|
- !ruby/object:Gem::Version
|
70
68
|
version: '3.1'
|
69
|
+
none: false
|
70
|
+
name: railties
|
71
71
|
type: :runtime
|
72
72
|
prerelease: false
|
73
|
-
|
74
|
-
none: false
|
73
|
+
requirement: !ruby/object:Gem::Requirement
|
75
74
|
requirements:
|
76
75
|
- - ~>
|
77
76
|
- !ruby/object:Gem::Version
|
78
77
|
version: '3.1'
|
78
|
+
none: false
|
79
79
|
description: Flexible authentication solution for Rails with Warden
|
80
80
|
email: contact@plataformatec.com.br
|
81
81
|
executables: []
|
@@ -85,6 +85,7 @@ files:
|
|
85
85
|
- .gitignore
|
86
86
|
- .travis.yml
|
87
87
|
- CHANGELOG.rdoc
|
88
|
+
- CONTRIBUTING.md
|
88
89
|
- Gemfile
|
89
90
|
- Gemfile.lock
|
90
91
|
- MIT-LICENSE
|
@@ -159,6 +160,7 @@ files:
|
|
159
160
|
- lib/devise/strategies/rememberable.rb
|
160
161
|
- lib/devise/strategies/token_authenticatable.rb
|
161
162
|
- lib/devise/test_helpers.rb
|
163
|
+
- lib/devise/time_inflector.rb
|
162
164
|
- lib/devise/version.rb
|
163
165
|
- lib/generators/active_record/devise_generator.rb
|
164
166
|
- lib/generators/active_record/templates/migration.rb
|
@@ -194,7 +196,6 @@ files:
|
|
194
196
|
- test/generators/mongoid_generator_test.rb
|
195
197
|
- test/generators/views_generator_test.rb
|
196
198
|
- test/helpers/devise_helper_test.rb
|
197
|
-
- test/indifferent_hash.rb
|
198
199
|
- test/integration/authenticatable_test.rb
|
199
200
|
- test/integration/confirmable_test.rb
|
200
201
|
- test/integration/database_authenticatable_test.rb
|
@@ -287,6 +288,7 @@ files:
|
|
287
288
|
- test/support/webrat/integrations/rails.rb
|
288
289
|
- test/test_helper.rb
|
289
290
|
- test/test_helpers_test.rb
|
291
|
+
- test/test_models.rb
|
290
292
|
homepage: http://github.com/plataformatec/devise
|
291
293
|
licenses: []
|
292
294
|
post_install_message:
|
@@ -294,17 +296,17 @@ rdoc_options: []
|
|
294
296
|
require_paths:
|
295
297
|
- lib
|
296
298
|
required_ruby_version: !ruby/object:Gem::Requirement
|
297
|
-
none: false
|
298
299
|
requirements:
|
299
300
|
- - ! '>='
|
300
301
|
- !ruby/object:Gem::Version
|
301
302
|
version: '0'
|
302
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
303
303
|
none: false
|
304
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
304
305
|
requirements:
|
305
|
-
- - ! '
|
306
|
+
- - ! '>'
|
306
307
|
- !ruby/object:Gem::Version
|
307
|
-
version:
|
308
|
+
version: 1.3.1
|
309
|
+
none: false
|
308
310
|
requirements: []
|
309
311
|
rubyforge_project: devise
|
310
312
|
rubygems_version: 1.8.23
|
@@ -326,7 +328,6 @@ test_files:
|
|
326
328
|
- test/generators/mongoid_generator_test.rb
|
327
329
|
- test/generators/views_generator_test.rb
|
328
330
|
- test/helpers/devise_helper_test.rb
|
329
|
-
- test/indifferent_hash.rb
|
330
331
|
- test/integration/authenticatable_test.rb
|
331
332
|
- test/integration/confirmable_test.rb
|
332
333
|
- test/integration/database_authenticatable_test.rb
|
@@ -419,3 +420,4 @@ test_files:
|
|
419
420
|
- test/support/webrat/integrations/rails.rb
|
420
421
|
- test/test_helper.rb
|
421
422
|
- test/test_helpers_test.rb
|
423
|
+
- test/test_models.rb
|