mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Remove deprecation warning, extract SessionSerializer and release new version.
This commit is contained in:
parent
35370e9e86
commit
e51e19c08c
5 changed files with 28 additions and 27 deletions
|
@ -1,3 +1,12 @@
|
|||
== 0.7.0
|
||||
|
||||
* deprecations
|
||||
* :authenticatable is not included by default anymore
|
||||
|
||||
* enhancements
|
||||
* Improve loading process
|
||||
* Extract SessionSerializer from Authenticatable
|
||||
|
||||
== 0.6.3
|
||||
|
||||
* bug fix
|
||||
|
@ -19,7 +28,7 @@
|
|||
== 0.6.0
|
||||
|
||||
* deprecations
|
||||
* :authenticatable is not included by default anymore
|
||||
* :authenticatable is still included by default, but yields a deprecation warning
|
||||
|
||||
* enhancements
|
||||
* Added DataMapper support
|
||||
|
|
|
@ -3,7 +3,8 @@ module Devise
|
|||
autoload :Authenticatable, 'devise/models/authenticatable'
|
||||
autoload :Confirmable, 'devise/models/confirmable'
|
||||
autoload :Recoverable, 'devise/models/recoverable'
|
||||
autoload :Rememberable, 'devise/models/rememberable'
|
||||
autoload :Rememberable, 'devise/models/rememberable'
|
||||
autoload :SessionSerializer, 'devise/models/authenticatable'
|
||||
autoload :Timeoutable, 'devise/models/timeoutable'
|
||||
autoload :Trackable, 'devise/models/trackable'
|
||||
autoload :Validatable, 'devise/models/validatable'
|
||||
|
@ -77,19 +78,13 @@ module Devise
|
|||
# devise :all, :except => :recoverable
|
||||
#
|
||||
def devise(*modules)
|
||||
# TODO Add this check in future versions
|
||||
# raise "You need to give at least one Devise module" if modules.empty?
|
||||
raise "You need to give at least one Devise module" if modules.empty?
|
||||
|
||||
options = modules.extract_options!
|
||||
modules = Devise.all if modules.include?(:all)
|
||||
modules -= Array(options.delete(:except))
|
||||
modules = Devise::ALL & modules
|
||||
|
||||
if !modules.include?(:authenticatable)
|
||||
modules = [:authenticatable] | modules
|
||||
ActiveSupport::Deprecation.warn ":authenticatable won't be included by default in devise in future versions, please add it", caller[0,10]
|
||||
end
|
||||
|
||||
Devise.orm_class.included_modules_hook(self, modules) do
|
||||
modules.each do |m|
|
||||
devise_modules << m.to_sym
|
||||
|
|
|
@ -3,6 +3,19 @@ require 'devise/serializers/authenticatable'
|
|||
|
||||
module Devise
|
||||
module Models
|
||||
module SessionSerializer
|
||||
# Hook to serialize user into session. Overwrite if you want.
|
||||
def serialize_into_session(record)
|
||||
[record.class, record.id]
|
||||
end
|
||||
|
||||
# Hook to serialize user from session. Overwrite if you want.
|
||||
def serialize_from_session(keys)
|
||||
klass, id = keys
|
||||
raise "#{self} cannot serialize from #{klass} session since it's not its ancestors" unless klass <= self
|
||||
klass.find(:first, :conditions => { :id => id })
|
||||
end
|
||||
end
|
||||
|
||||
# Authenticable Module, responsible for encrypting password and validating
|
||||
# authenticity of a user while signing in.
|
||||
|
@ -32,6 +45,7 @@ module Devise
|
|||
def self.included(base)
|
||||
base.class_eval do
|
||||
extend ClassMethods
|
||||
extend SessionSerializer
|
||||
|
||||
attr_reader :password
|
||||
attr_accessor :password_confirmation
|
||||
|
@ -71,18 +85,6 @@ module Devise
|
|||
valid_for_authentication(resource, attributes) if resource
|
||||
end
|
||||
|
||||
# Hook to serialize user into session. Overwrite if you want.
|
||||
def serialize_into_session(record)
|
||||
[record.class, record.id]
|
||||
end
|
||||
|
||||
# Hook to serialize user from session. Overwrite if you want.
|
||||
def serialize_from_session(keys)
|
||||
klass, id = keys
|
||||
raise "#{self} cannot serialize from #{klass} session since it's not its ancestors" unless klass <= self
|
||||
klass.find(:first, :conditions => { :id => id })
|
||||
end
|
||||
|
||||
# Returns the class for the configured encryptor.
|
||||
def encryptor_class
|
||||
@encryptor_class ||= ::Devise::Encryptors.const_get(encryptor.to_s.classify)
|
||||
|
|
|
@ -79,11 +79,6 @@ module ActionController::Routing
|
|||
def devise_for(*resources)
|
||||
options = resources.extract_options!
|
||||
|
||||
if singular = options.delete(:singular)
|
||||
ActiveSupport::Deprecation.warn ":singular is deprecated in devise_for, use :scope instead."
|
||||
options[:scope] = singular
|
||||
end
|
||||
|
||||
resources.map!(&:to_sym)
|
||||
resources.each do |resource|
|
||||
mapping = Devise::Mapping.new(resource, options.dup)
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
module Devise
|
||||
VERSION = "0.6.3".freeze
|
||||
VERSION = "0.7.0".freeze
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue