devise 1.5.1 → 1.5.2

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.

@@ -1,3 +1,12 @@
1
+ == 1.5.2
2
+
3
+ * enhancements
4
+ * Add support for rails 3.1 new mass assignment conventions (by github.com/kirs)
5
+ * Add timeout_in method to Timeoutable, it can be overriden in a model (by github.com/lest)
6
+
7
+ * bug fix
8
+ * OmniAuth error message now shows the proper option (:strategy_class instead of :klass)
9
+
1
10
  == 1.5.1
2
11
 
3
12
  * bug fix
@@ -72,7 +72,7 @@ We hope that you will consider contributing to Devise. Please read this short ov
72
72
 
73
73
  https://github.com/plataformatec/devise/wiki/Contributing
74
74
 
75
- You will usually want to write tests for your changes. To run the test suite, `cd` into Devise's top-level directory and run `bundle install` and `rake`. For the tests to pass, you will need to have a MongoDB server (version 1.6 or newer) running on your system.
75
+ You will usually want to write tests for your changes. To run the test suite, `cd` into Devise's top-level directory and run `bundle install` and `rake`. For the tests to pass, you will need to have a MongoDB server (version 2.0 or newer) running on your system.
76
76
 
77
77
  == Installation
78
78
 
@@ -88,7 +88,7 @@ The generator will install an initializer which describes ALL Devise's configura
88
88
 
89
89
  rails generate devise MODEL
90
90
 
91
- Replace MODEL by the class name used for the applications users, it's frequently 'User' but could also be 'Admin'. This will create a model (if one does not exist) and configure it with default Devise modules. Next, you'll usually run db:migrate as the generator will have created a migration file (if your ORM supports them). This generator also configures your config/routes.rb file, continue reading this file to understand exactly what the generator produces and how to use it.
91
+ Replace MODEL by the class name used for the applications users, it's frequently 'User' but could also be 'Admin'. This will create a model (if one does not exist) and configure it with default Devise modules. Next, you'll usually run db:migrate as the generator will have created a migration file (if your ORM supports them). This generator also configures your config/routes.rb file, continue reading this file to understand exactly what the generator produces and how to use it. Finally, if your server was already running, then restart it as Rails doesn't automatically load methods from a new gem.
92
92
 
93
93
  Support for Rails 2.3.x can be found by installing Devise 1.0.x from the v1.0 branch.
94
94
 
@@ -359,6 +359,7 @@ https://github.com/plataformatec/devise/contributors
359
359
 
360
360
  * José Valim (https://github.com/josevalim)
361
361
  * Carlos Antônio da Silva (https://github.com/carlosantoniodasilva)
362
+ * Rodrigo Flores (https://github.com/rodrigoflores)
362
363
 
363
364
  == License
364
365
 
@@ -51,7 +51,7 @@ module Devise
51
51
  # Update record attributes when :current_password matches, otherwise returns
52
52
  # error on :current_password. It also automatically rejects :password and
53
53
  # :password_confirmation if they are blank.
54
- def update_with_password(params={})
54
+ def update_with_password(params, *options)
55
55
  current_password = params.delete(:current_password)
56
56
 
57
57
  if params[:password].blank?
@@ -60,7 +60,7 @@ module Devise
60
60
  end
61
61
 
62
62
  result = if valid_password?(current_password)
63
- update_attributes(params)
63
+ update_attributes(params, *options)
64
64
  else
65
65
  self.attributes = params
66
66
  self.valid?
@@ -84,15 +84,15 @@ module Devise
84
84
  # super(params)
85
85
  # end
86
86
  #
87
- def update_without_password(params={})
87
+ def update_without_password(params, *options)
88
88
  params.delete(:password)
89
89
  params.delete(:password_confirmation)
90
90
 
91
- result = update_attributes(params)
91
+ result = update_attributes(params, *options)
92
92
  clean_up_passwords
93
93
  result
94
94
  end
95
-
95
+
96
96
  def after_database_authentication
97
97
  end
98
98
 
@@ -107,7 +107,7 @@ module Devise
107
107
  def downcase_keys
108
108
  (self.class.case_insensitive_keys || []).each { |k| self[k].try(:downcase!) }
109
109
  end
110
-
110
+
111
111
  def strip_whitespace
112
112
  (self.class.strip_whitespace_keys || []).each { |k| self[k].try(:strip!) }
113
113
  end
@@ -23,18 +23,22 @@ module Devise
23
23
  # Checks whether the user session has expired based on configured time.
24
24
  def timedout?(last_access)
25
25
  return false if remember_exists_and_not_expired?
26
-
27
- last_access && last_access <= self.class.timeout_in.ago
26
+
27
+ !timeout_in.nil? && last_access && last_access <= timeout_in.ago
28
+ end
29
+
30
+ def timeout_in
31
+ self.class.timeout_in
28
32
  end
29
-
33
+
30
34
  private
31
-
35
+
32
36
  def remember_exists_and_not_expired?
33
37
  return false unless respond_to?(:remember_expired?)
34
-
38
+
35
39
  remember_created_at && !remember_expired?
36
40
  end
37
-
41
+
38
42
  module ClassMethods
39
43
  Devise::Models.config(self, :timeout_in)
40
44
  end
@@ -4,7 +4,7 @@ module Devise
4
4
  def initialize(strategy)
5
5
  @strategy = strategy
6
6
  super("Could not find a strategy with name `#{strategy}'. " \
7
- "Please ensure it is required or explicitly set it using the :klass option.")
7
+ "Please ensure it is required or explicitly set it using the :strategy_class option.")
8
8
  end
9
9
  end
10
10
 
@@ -1,3 +1,3 @@
1
1
  module Devise
2
- VERSION = "1.5.1".freeze
2
+ VERSION = "1.5.2".freeze
3
3
  end
@@ -1,5 +1,5 @@
1
- # Use this hook to configure devise mailer, warden hooks and so forth. The first
2
- # four configuration values can also be set straight in your models.
1
+ # Use this hook to configure devise mailer, warden hooks and so forth.
2
+ # Many of these configuration options can be set straight in your model.
3
3
  Devise.setup do |config|
4
4
  # ==> Mailer Configuration
5
5
  # Configure the e-mail address which will be shown in Devise::Mailer,
@@ -87,6 +87,13 @@ class DatabaseAuthenticatableTest < ActiveSupport::TestCase
87
87
  assert user.reload.valid_password?('pass321')
88
88
  end
89
89
 
90
+ test 'should update password with valid current password and :as option' do
91
+ user = create_user
92
+ assert user.update_with_password(:current_password => '123456',
93
+ :password => 'pass321', :password_confirmation => 'pass321', :as => :admin)
94
+ assert user.reload.valid_password?('pass321')
95
+ end
96
+
90
97
  test 'should add an error to current password when it is invalid' do
91
98
  user = create_user
92
99
  assert_not user.update_with_password(:current_password => 'other',
@@ -138,6 +145,12 @@ class DatabaseAuthenticatableTest < ActiveSupport::TestCase
138
145
  user.update_without_password(:email => 'new@example.com')
139
146
  assert_equal 'new@example.com', user.email
140
147
  end
148
+
149
+ test 'should update the user without password with :as option' do
150
+ user = create_user
151
+ user.update_without_password(:email => 'new@example.com', :as => :admin)
152
+ assert_equal 'new@example.com', user.email
153
+ end
141
154
 
142
155
  test 'should not update password without password' do
143
156
  user = create_user
@@ -14,6 +14,20 @@ class TimeoutableTest < ActiveSupport::TestCase
14
14
  assert_not new_user.timedout?(nil)
15
15
  end
16
16
 
17
+ test 'should use timeout_in method' do
18
+ user = new_user
19
+ user.instance_eval { def timeout_in; 10.minutes end }
20
+
21
+ assert user.timedout?(12.minutes.ago)
22
+ assert_not user.timedout?(8.minutes.ago)
23
+ end
24
+
25
+ test 'should not be expired when timeout_in method returns nil' do
26
+ user = new_user
27
+ user.instance_eval { def timeout_in; nil end }
28
+ assert_not user.timedout?(10.hours.ago)
29
+ end
30
+
17
31
  test 'fallback to Devise config option' do
18
32
  swap Devise, :timeout_in => 1.minute do
19
33
  user = new_user
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.5.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-11-22 00:00:00.000000000 Z
13
+ date: 2011-11-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: warden
17
- requirement: &70325690146000 !ruby/object:Gem::Requirement
17
+ requirement: &70351586247440 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '1.1'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70325690146000
25
+ version_requirements: *70351586247440
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: orm_adapter
28
- requirement: &70325690145300 !ruby/object:Gem::Requirement
28
+ requirement: &70351586246900 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 0.0.3
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *70325690145300
36
+ version_requirements: *70351586246900
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: bcrypt-ruby
39
- requirement: &70325690144180 !ruby/object:Gem::Requirement
39
+ requirement: &70351586246440 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,7 +44,7 @@ dependencies:
44
44
  version: '3.0'
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *70325690144180
47
+ version_requirements: *70351586246440
48
48
  description: Flexible authentication solution for Rails with Warden
49
49
  email: contact@plataformatec.com.br
50
50
  executables: []