lib/devise.rb in devise-0.9.1 vs lib/devise.rb in devise-0.9.2
- old
+ new
@@ -24,26 +24,38 @@
autoload :ActiveRecord, 'devise/orm/active_record'
autoload :DataMapper, 'devise/orm/data_mapper'
autoload :MongoMapper, 'devise/orm/mongo_mapper'
end
- ALL = [:authenticatable, :activatable, :confirmable, :recoverable,
- :rememberable, :validatable, :trackable, :timeoutable, :lockable]
+ ALL = []
+ # Authentication ones first
+ ALL.push :authenticatable, :token_authenticatable, :rememberable
+
+ # Misc after
+ ALL.push :recoverable, :validatable
+
+ # The ones which can sign out after
+ ALL.push :activatable, :confirmable, :lockable, :timeoutable
+
+ # Stats for last, so we make sure the user is really signed in
+ ALL.push :trackable
+
# Maps controller names to devise modules
CONTROLLERS = {
- :sessions => [:authenticatable],
+ :sessions => [:authenticatable, :token_authenticatable],
:passwords => [:recoverable],
:confirmations => [:confirmable],
:unlocks => [:lockable]
}
- STRATEGIES = [:rememberable, :authenticatable]
+ STRATEGIES = [:rememberable, :token_authenticatable, :authenticatable]
+
TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE']
# Maps the messages types that are used in flash message.
- FLASH_MESSAGES = [ :unauthenticated, :unconfirmed, :invalid, :timeout, :inactive, :locked ]
+ FLASH_MESSAGES = [ :unauthenticated, :unconfirmed, :invalid, :invalid_token, :timeout, :inactive, :locked ]
# Declare encryptors length which are used in migrations.
ENCRYPTORS_LENGTH = {
:sha1 => 40,
:sha512 => 128,
@@ -51,12 +63,12 @@
:restful_authentication_sha1 => 40,
:authlogic_sha512 => 128,
:bcrypt => 60
}
- # Email regex used to validate email formats. Retrieved from authlogic.
- EMAIL_REGEX = /\A[\w\.%\+\-]+@(?:[A-Z0-9\-]+\.)+(?:[A-Z]{2,4}|museum|travel)\z/i
+ # Email regex used to validate email formats. Adapted from authlogic.
+ EMAIL_REGEX = /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i
# Used to encrypt password. Please generate one with rake secret.
mattr_accessor :pepper
@@pepper = nil
@@ -128,9 +140,13 @@
@@default_scope = nil
# Address which sends Devise e-mails.
mattr_accessor :mailer_sender
@@mailer_sender
+
+ # Authentication token params key name of choice. E.g. /users/sign_in?some_key=...
+ mattr_accessor :token_authentication_key
+ @@token_authentication_key = :auth_token
class << self
# Default way to setup Devise. Run script/generate devise_install to create
# a fresh initializer with all configuration values.
def setup
\ No newline at end of file