devise 0.6.3 → 0.7.0
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 +10 -1
- data/README.rdoc +4 -5
- data/lib/devise.rb +5 -6
- data/lib/devise/models.rb +10 -7
- data/lib/devise/models/authenticatable.rb +15 -13
- data/lib/devise/models/validatable.rb +4 -6
- data/lib/devise/orm.rb +7 -0
- data/lib/devise/rails/routes.rb +0 -5
- data/lib/devise/serializers/authenticatable.rb +3 -1
- data/lib/devise/serializers/base.rb +2 -0
- data/lib/devise/serializers/rememberable.rb +2 -0
- data/lib/devise/strategies/authenticatable.rb +2 -0
- data/lib/devise/version.rb +1 -1
- metadata +3 -2
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
== 0.7.0
|
2
|
+
|
3
|
+
* deprecations
|
4
|
+
* :authenticatable is not included by default anymore
|
5
|
+
|
6
|
+
* enhancements
|
7
|
+
* Improve loading process
|
8
|
+
* Extract SessionSerializer from Authenticatable
|
9
|
+
|
1
10
|
== 0.6.3
|
2
11
|
|
3
12
|
* bug fix
|
@@ -19,7 +28,7 @@
|
|
19
28
|
== 0.6.0
|
20
29
|
|
21
30
|
* deprecations
|
22
|
-
* :authenticatable is
|
31
|
+
* :authenticatable is still included by default, but yields a deprecation warning
|
23
32
|
|
24
33
|
* enhancements
|
25
34
|
* Added DataMapper support
|
data/README.rdoc
CHANGED
@@ -223,9 +223,7 @@ Take a look at our locale file to check all available messages.
|
|
223
223
|
|
224
224
|
== Test helpers
|
225
225
|
|
226
|
-
Devise includes some tests helpers for functional specs. To use them, you just
|
227
|
-
need to include Devise::TestHelpers in your test class and use the sign_in and
|
228
|
-
sign_out method. Such methods have the same signature as in controllers:
|
226
|
+
Devise includes some tests helpers for functional specs. To use them, you just need to include Devise::TestHelpers in your test class and use the sign_in and sign_out method. Such methods have the same signature as in controllers:
|
229
227
|
|
230
228
|
sign_in :user, @user # sign_in(scope, resource)
|
231
229
|
sign_in @user # sign_in(resource)
|
@@ -233,13 +231,14 @@ sign_out method. Such methods have the same signature as in controllers:
|
|
233
231
|
sign_out :user # sign_out(scope)
|
234
232
|
sign_out @user # sign_out(resource)
|
235
233
|
|
236
|
-
You can include the Devise Test Helpers in all of your tests by adding the
|
237
|
-
following to the bottom of your test/test_helper.rb or spec/spec_helper.rb file:
|
234
|
+
You can include the Devise Test Helpers in all of your tests by adding the following to the bottom of your test/test_helper.rb or spec/spec_helper.rb file:
|
238
235
|
|
239
236
|
class ActionController::TestCase
|
240
237
|
include Devise::TestHelpers
|
241
238
|
end
|
242
239
|
|
240
|
+
Do not use such helpers for integration tests like Cucumber, Webrat... Just fill in the form or explicitly set the user in session. For more tips, check the wiki (http://wiki.github.com/plataformatec/devise).
|
241
|
+
|
243
242
|
== Migrating from other solutions
|
244
243
|
|
245
244
|
Devise implements encryption strategies for Clearance, Authlogic and Restful-Authentication. To make use of it set the desired encryptor in the encryptor initializer config option. You might also need to rename your encrypted password and salt columns to match Devises's one (encrypted_password and password_salt).
|
data/lib/devise.rb
CHANGED
@@ -4,7 +4,7 @@ module Devise
|
|
4
4
|
autoload :FailureApp, 'devise/failure_app'
|
5
5
|
|
6
6
|
ALL = [:authenticatable, :confirmable, :recoverable, :rememberable,
|
7
|
-
:timeoutable, :trackable, :validatable]
|
7
|
+
:timeoutable, :trackable, :validatable]
|
8
8
|
|
9
9
|
# Maps controller names to devise modules
|
10
10
|
CONTROLLERS = {
|
@@ -13,9 +13,9 @@ module Devise
|
|
13
13
|
:confirmations => :confirmable
|
14
14
|
}.freeze
|
15
15
|
|
16
|
-
STRATEGIES = [:authenticatable]
|
17
|
-
SERIALIZERS = [:authenticatable, :rememberable]
|
18
|
-
TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE']
|
16
|
+
STRATEGIES = [:authenticatable]
|
17
|
+
SERIALIZERS = [:authenticatable, :rememberable]
|
18
|
+
TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE']
|
19
19
|
|
20
20
|
# Maps the messages types that are used in flash message. This array is not
|
21
21
|
# frozen, so you can add messages from your own strategies.
|
@@ -150,6 +150,5 @@ Warden::Manager.default_scope = nil
|
|
150
150
|
|
151
151
|
require 'devise/controllers'
|
152
152
|
require 'devise/encryptors'
|
153
|
-
require 'devise/
|
154
|
-
require 'devise/serializers/base'
|
153
|
+
require 'devise/orm'
|
155
154
|
require 'devise/rails'
|
data/lib/devise/models.rb
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
module Devise
|
2
2
|
module Models
|
3
|
+
autoload :Authenticatable, 'devise/models/authenticatable'
|
4
|
+
autoload :Confirmable, 'devise/models/confirmable'
|
5
|
+
autoload :Recoverable, 'devise/models/recoverable'
|
6
|
+
autoload :Rememberable, 'devise/models/rememberable'
|
7
|
+
autoload :SessionSerializer, 'devise/models/authenticatable'
|
8
|
+
autoload :Timeoutable, 'devise/models/timeoutable'
|
9
|
+
autoload :Trackable, 'devise/models/trackable'
|
10
|
+
autoload :Validatable, 'devise/models/validatable'
|
11
|
+
|
3
12
|
# Creates configuration values for Devise and for the given module.
|
4
13
|
#
|
5
14
|
# Devise::Models.config(Devise::Authenticable, :stretches, 10)
|
@@ -69,19 +78,13 @@ module Devise
|
|
69
78
|
# devise :all, :except => :recoverable
|
70
79
|
#
|
71
80
|
def devise(*modules)
|
72
|
-
|
73
|
-
# raise "You need to give at least one Devise module" if modules.empty?
|
81
|
+
raise "You need to give at least one Devise module" if modules.empty?
|
74
82
|
|
75
83
|
options = modules.extract_options!
|
76
84
|
modules = Devise.all if modules.include?(:all)
|
77
85
|
modules -= Array(options.delete(:except))
|
78
86
|
modules = Devise::ALL & modules
|
79
87
|
|
80
|
-
if !modules.include?(:authenticatable)
|
81
|
-
modules = [:authenticatable] | modules
|
82
|
-
ActiveSupport::Deprecation.warn ":authenticatable won't be included by default in devise in future versions, please add it", caller[0,10]
|
83
|
-
end
|
84
|
-
|
85
88
|
Devise.orm_class.included_modules_hook(self, modules) do
|
86
89
|
modules.each do |m|
|
87
90
|
devise_modules << m.to_sym
|
@@ -3,6 +3,19 @@ require 'devise/serializers/authenticatable'
|
|
3
3
|
|
4
4
|
module Devise
|
5
5
|
module Models
|
6
|
+
module SessionSerializer
|
7
|
+
# Hook to serialize user into session. Overwrite if you want.
|
8
|
+
def serialize_into_session(record)
|
9
|
+
[record.class, record.id]
|
10
|
+
end
|
11
|
+
|
12
|
+
# Hook to serialize user from session. Overwrite if you want.
|
13
|
+
def serialize_from_session(keys)
|
14
|
+
klass, id = keys
|
15
|
+
raise "#{self} cannot serialize from #{klass} session since it's not its ancestors" unless klass <= self
|
16
|
+
klass.find(:first, :conditions => { :id => id })
|
17
|
+
end
|
18
|
+
end
|
6
19
|
|
7
20
|
# Authenticable Module, responsible for encrypting password and validating
|
8
21
|
# authenticity of a user while signing in.
|
@@ -32,6 +45,7 @@ module Devise
|
|
32
45
|
def self.included(base)
|
33
46
|
base.class_eval do
|
34
47
|
extend ClassMethods
|
48
|
+
extend SessionSerializer
|
35
49
|
|
36
50
|
attr_reader :password
|
37
51
|
attr_accessor :password_confirmation
|
@@ -63,7 +77,7 @@ module Devise
|
|
63
77
|
module ClassMethods
|
64
78
|
# Authenticate a user based on configured attribute keys. Returns the
|
65
79
|
# authenticated user if it's valid or nil. Attributes are by default
|
66
|
-
# :email and :password, the latter is always required.
|
80
|
+
# :email and :password, but the latter is always required.
|
67
81
|
def authenticate(attributes={})
|
68
82
|
return unless authentication_keys.all? { |k| attributes[k].present? }
|
69
83
|
conditions = attributes.slice(*authentication_keys)
|
@@ -71,18 +85,6 @@ module Devise
|
|
71
85
|
valid_for_authentication(resource, attributes) if resource
|
72
86
|
end
|
73
87
|
|
74
|
-
# Hook to serialize user into session. Overwrite if you want.
|
75
|
-
def serialize_into_session(record)
|
76
|
-
[record.class, record.id]
|
77
|
-
end
|
78
|
-
|
79
|
-
# Hook to serialize user from session. Overwrite if you want.
|
80
|
-
def serialize_from_session(keys)
|
81
|
-
klass, id = keys
|
82
|
-
raise "#{self} cannot serialize from #{klass} session since it's not its ancestors" unless klass <= self
|
83
|
-
klass.find(:first, :conditions => { :id => id })
|
84
|
-
end
|
85
|
-
|
86
88
|
# Returns the class for the configured encryptor.
|
87
89
|
def encryptor_class
|
88
90
|
@encryptor_class ||= ::Devise::Encryptors.const_get(encryptor.to_s.classify)
|
@@ -18,12 +18,10 @@ module Devise
|
|
18
18
|
assert_validations_api!(base)
|
19
19
|
|
20
20
|
base.class_eval do
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
validates_format_of attribute, :with => EMAIL_REGEX, :allow_blank => true,
|
26
|
-
:scope => authentication_keys[1..-1]
|
21
|
+
validates_presence_of :email
|
22
|
+
validates_uniqueness_of :email, :allow_blank => true
|
23
|
+
validates_format_of :email, :with => EMAIL_REGEX, :allow_blank => true,
|
24
|
+
:scope => authentication_keys[1..-1]
|
27
25
|
|
28
26
|
with_options :if => :password_required? do |v|
|
29
27
|
v.validates_presence_of :password
|
data/lib/devise/orm.rb
ADDED
data/lib/devise/rails/routes.rb
CHANGED
@@ -79,11 +79,6 @@ module ActionController::Routing
|
|
79
79
|
def devise_for(*resources)
|
80
80
|
options = resources.extract_options!
|
81
81
|
|
82
|
-
if singular = options.delete(:singular)
|
83
|
-
ActiveSupport::Deprecation.warn ":singular is deprecated in devise_for, use :scope instead."
|
84
|
-
options[:scope] = singular
|
85
|
-
end
|
86
|
-
|
87
82
|
resources.map!(&:to_sym)
|
88
83
|
resources.each do |resource|
|
89
84
|
mapping = Devise::Mapping.new(resource, options.dup)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'devise/serializers/base'
|
2
|
+
|
1
3
|
module Devise
|
2
4
|
module Serializers
|
3
5
|
class Authenticatable < Warden::Serializers::Session
|
@@ -6,4 +8,4 @@ module Devise
|
|
6
8
|
end
|
7
9
|
end
|
8
10
|
|
9
|
-
Warden::Serializers.add(:authenticatable, Devise::Serializers::Authenticatable)
|
11
|
+
Warden::Serializers.add(:authenticatable, Devise::Serializers::Authenticatable)
|
data/lib/devise/version.rb
CHANGED
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: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Jos\xC3\xA9 Valim"
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-12-
|
13
|
+
date: 2009-12-08 00:00:00 -02:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -84,6 +84,7 @@ files:
|
|
84
84
|
- lib/devise/models/timeoutable.rb
|
85
85
|
- lib/devise/models/trackable.rb
|
86
86
|
- lib/devise/models/validatable.rb
|
87
|
+
- lib/devise/orm.rb
|
87
88
|
- lib/devise/orm/active_record.rb
|
88
89
|
- lib/devise/orm/data_mapper.rb
|
89
90
|
- lib/devise/orm/mongo_mapper.rb
|