mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Merge branch 'master' of github.com:plataformatec/devise
This commit is contained in:
commit
5735b21c77
12 changed files with 56 additions and 34 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
|
||||
|
|
|
@ -223,9 +223,7 @@ Take a look at our locale file to check all available messages.
|
|||
|
||||
== Test helpers
|
||||
|
||||
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:
|
||||
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:
|
||||
|
||||
sign_in :user, @user # sign_in(scope, resource)
|
||||
sign_in @user # sign_in(resource)
|
||||
|
@ -233,13 +231,14 @@ sign_out method. Such methods have the same signature as in controllers:
|
|||
sign_out :user # sign_out(scope)
|
||||
sign_out @user # sign_out(resource)
|
||||
|
||||
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:
|
||||
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:
|
||||
|
||||
class ActionController::TestCase
|
||||
include Devise::TestHelpers
|
||||
end
|
||||
|
||||
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).
|
||||
|
||||
== Migrating from other solutions
|
||||
|
||||
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).
|
||||
|
|
|
@ -150,6 +150,5 @@ Warden::Manager.default_scope = nil
|
|||
|
||||
require 'devise/controllers'
|
||||
require 'devise/encryptors'
|
||||
require 'devise/strategies/base'
|
||||
require 'devise/serializers/base'
|
||||
require 'devise/orm'
|
||||
require 'devise/rails'
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
module Devise
|
||||
module Models
|
||||
autoload :Authenticatable, 'devise/models/authenticatable'
|
||||
autoload :Confirmable, 'devise/models/confirmable'
|
||||
autoload :Recoverable, 'devise/models/recoverable'
|
||||
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'
|
||||
|
||||
# Creates configuration values for Devise and for the given module.
|
||||
#
|
||||
# Devise::Models.config(Devise::Authenticable, :stretches, 10)
|
||||
|
@ -69,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)
|
||||
|
|
7
lib/devise/orm.rb
Normal file
7
lib/devise/orm.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
module Devise
|
||||
module Orm
|
||||
autoload :ActiveRecord, 'devise/orm/active_record'
|
||||
autoload :DataMapper, 'devise/orm/data_mapper'
|
||||
autoload :MongoMapper, 'devise/orm/mongo_mapper'
|
||||
end
|
||||
end
|
|
@ -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,5 @@
|
|||
require 'devise/serializers/base'
|
||||
|
||||
module Devise
|
||||
module Serializers
|
||||
class Authenticatable < Warden::Serializers::Session
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
require 'devise/strategies/base'
|
||||
|
||||
module Devise
|
||||
module Serializers
|
||||
module Base
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
require 'devise/serializers/base'
|
||||
|
||||
module Devise
|
||||
module Serializers
|
||||
class Rememberable < Warden::Serializers::Cookie
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
require 'devise/strategies/base'
|
||||
|
||||
module Devise
|
||||
module Strategies
|
||||
# Default strategy for signing in a user, based on his email and password.
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
module Devise
|
||||
VERSION = "0.6.3".freeze
|
||||
VERSION = "0.7.0".freeze
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue