devise 0.5.2 → 0.5.3
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 +12 -0
- data/app/controllers/sessions_controller.rb +2 -2
- data/generators/devise_install/devise_install_generator.rb +1 -1
- data/generators/devise_install/templates/devise.rb +5 -0
- data/lib/devise.rb +18 -12
- data/lib/devise/controllers/helpers.rb +2 -0
- data/lib/devise/models.rb +1 -1
- data/lib/devise/models/authenticatable.rb +2 -7
- data/lib/devise/models/confirmable.rb +1 -1
- data/lib/devise/models/recoverable.rb +1 -1
- data/lib/devise/models/rememberable.rb +1 -1
- data/lib/devise/orm/mongo_mapper.rb +5 -2
- data/lib/devise/version.rb +1 -1
- metadata +2 -2
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
== 0.5.3
|
2
|
+
|
3
|
+
* bug fix
|
4
|
+
* MongoMapper now converts DateTime to Time
|
5
|
+
* Ensure all controllers are unloadable
|
6
|
+
|
7
|
+
* enhancements
|
8
|
+
* [#35] Moved friendly_token to Devise
|
9
|
+
* Added Devise.all, so you can freeze your app strategies
|
10
|
+
* Added Devise.apply_schema, so you can turn it to false in Datamapper or MongoMapper
|
11
|
+
in cases you don't want it be handlded automatically
|
12
|
+
|
1
13
|
== 0.5.2
|
2
14
|
|
3
15
|
* enhancements
|
@@ -5,8 +5,8 @@ class SessionsController < ApplicationController
|
|
5
5
|
|
6
6
|
# GET /resource/sign_in
|
7
7
|
def new
|
8
|
-
Devise::FLASH_MESSAGES.each do |message
|
9
|
-
set_now_flash_message
|
8
|
+
Devise::FLASH_MESSAGES.each do |message|
|
9
|
+
set_now_flash_message :failure, message if params.try(:[], message) == "true"
|
10
10
|
end
|
11
11
|
build_resource
|
12
12
|
end
|
@@ -1,6 +1,11 @@
|
|
1
1
|
# Use this hook to configure devise mailer, warden hooks and so forth. The first
|
2
2
|
# four configuration values can also be set straight in your models.
|
3
3
|
Devise.setup do |config|
|
4
|
+
# Configure the frameworks used by default. You should always set this value
|
5
|
+
# because if Devise add a new strategy, it won't be added to your application
|
6
|
+
# by default, unless you configure it here.
|
7
|
+
config.all = <%= Devise::ALL.inspect %>
|
8
|
+
|
4
9
|
# Invoke `rake secret` and use the printed value to setup a pepper to generate
|
5
10
|
# the encrypted password. By default no pepper is used.
|
6
11
|
# config.pepper = "rake secret output"
|
data/lib/devise.rb
CHANGED
@@ -12,12 +12,9 @@ module Devise
|
|
12
12
|
SERIALIZERS = [:authenticatable, :rememberable].freeze
|
13
13
|
TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE'].freeze
|
14
14
|
|
15
|
-
# Maps the messages types that
|
16
|
-
#
|
17
|
-
FLASH_MESSAGES =
|
18
|
-
:unauthenticated => :success,
|
19
|
-
:unconfirmed => :failure
|
20
|
-
}
|
15
|
+
# Maps the messages types that are used in flash message. This array is not
|
16
|
+
# frozen, so you can add messages from your own strategies.
|
17
|
+
FLASH_MESSAGES = [ :unauthenticated, :unconfirmed, :invalid ]
|
21
18
|
|
22
19
|
# Declare encryptors length which are used in migrations.
|
23
20
|
ENCRYPTORS_LENGTH = {
|
@@ -28,7 +25,7 @@ module Devise
|
|
28
25
|
:authlogic_sha512 => 128
|
29
26
|
}
|
30
27
|
|
31
|
-
# Used to encrypt password. Please generate one with rake secret
|
28
|
+
# Used to encrypt password. Please generate one with rake secret.
|
32
29
|
mattr_accessor :pepper
|
33
30
|
@@pepper = nil
|
34
31
|
|
@@ -67,6 +64,15 @@ module Devise
|
|
67
64
|
mattr_accessor :orm
|
68
65
|
@@orm = :active_record
|
69
66
|
|
67
|
+
# Configure default options used in :all.
|
68
|
+
mattr_accessor :all
|
69
|
+
@@all = Devise::ALL.dup
|
70
|
+
|
71
|
+
# Tells if devise should apply the schema in ORMs where devise declaration
|
72
|
+
# and schema belongs to the same class (as Datamapper and MongoMapper).
|
73
|
+
mattr_accessor :apply_schema
|
74
|
+
@@apply_schema = true
|
75
|
+
|
70
76
|
class << self
|
71
77
|
# Default way to setup Devise. Run script/generate devise_install to create
|
72
78
|
# a fresh initializer with all configuration values.
|
@@ -74,11 +80,6 @@ module Devise
|
|
74
80
|
yield self
|
75
81
|
end
|
76
82
|
|
77
|
-
def mail_sender=(value) #:nodoc:
|
78
|
-
ActiveSupport::Deprecation.warn "Devise.mail_sender= is deprecated, use Devise.mailer_sender instead"
|
79
|
-
DeviseMailer.sender = value
|
80
|
-
end
|
81
|
-
|
82
83
|
# Sets the sender in DeviseMailer.
|
83
84
|
def mailer_sender=(value)
|
84
85
|
DeviseMailer.sender = value
|
@@ -122,6 +123,11 @@ module Devise
|
|
122
123
|
def orm_class
|
123
124
|
Devise::Orm.const_get(@@orm.to_s.camelize.to_sym)
|
124
125
|
end
|
126
|
+
|
127
|
+
# Generate a friendly string randomically to be used as token.
|
128
|
+
def friendly_token
|
129
|
+
ActiveSupport::SecureRandom.base64(15).tr('+/=', '-_ ').strip.delete("\n")
|
130
|
+
end
|
125
131
|
end
|
126
132
|
end
|
127
133
|
|
@@ -7,6 +7,8 @@ module Devise
|
|
7
7
|
|
8
8
|
def self.included(base)
|
9
9
|
base.class_eval do
|
10
|
+
unloadable
|
11
|
+
|
10
12
|
helper_method :resource, :resource_name, :resource_class, :devise_mapping, :devise_controller?
|
11
13
|
hide_action :resource, :resource_name, :resource_class, :devise_mapping, :devise_controller?
|
12
14
|
|
data/lib/devise/models.rb
CHANGED
@@ -83,7 +83,7 @@ module Devise
|
|
83
83
|
def devise(*modules)
|
84
84
|
options = modules.extract_options!
|
85
85
|
|
86
|
-
modules = Devise
|
86
|
+
modules = Devise.all if modules.include?(:all)
|
87
87
|
modules -= Array(options.delete(:except))
|
88
88
|
modules = [:authenticatable] | modules
|
89
89
|
|
@@ -42,7 +42,7 @@ module Devise
|
|
42
42
|
# setted.
|
43
43
|
def password=(new_password)
|
44
44
|
@password = new_password
|
45
|
-
self.password_salt = friendly_token
|
45
|
+
self.password_salt = Devise.friendly_token
|
46
46
|
self.encrypted_password = password_digest(@password)
|
47
47
|
end
|
48
48
|
|
@@ -53,16 +53,11 @@ module Devise
|
|
53
53
|
end
|
54
54
|
|
55
55
|
protected
|
56
|
-
|
56
|
+
|
57
57
|
# Digests the password using the configured encryptor
|
58
58
|
def password_digest(password)
|
59
59
|
encryptor.digest(password, stretches, password_salt, pepper)
|
60
60
|
end
|
61
|
-
|
62
|
-
# Generate a friendly string randomically to be used as token.
|
63
|
-
def friendly_token
|
64
|
-
ActiveSupport::SecureRandom.base64(15).tr('+/=', '-_ ').strip.delete("\n")
|
65
|
-
end
|
66
61
|
|
67
62
|
module ClassMethods
|
68
63
|
# Authenticate a user based on email and password. Returns the
|
@@ -119,7 +119,7 @@ module Devise
|
|
119
119
|
# this token is being generated
|
120
120
|
def generate_confirmation_token
|
121
121
|
self.confirmed_at = nil
|
122
|
-
self.confirmation_token = friendly_token
|
122
|
+
self.confirmation_token = Devise.friendly_token
|
123
123
|
self.confirmation_sent_at = Time.now.utc
|
124
124
|
end
|
125
125
|
|
@@ -42,7 +42,7 @@ module Devise
|
|
42
42
|
|
43
43
|
# Generates a new random token for reset password
|
44
44
|
def generate_reset_password_token
|
45
|
-
self.reset_password_token = friendly_token
|
45
|
+
self.reset_password_token = Devise.friendly_token
|
46
46
|
end
|
47
47
|
|
48
48
|
# Resets the reset password token with and save the record without
|
@@ -43,7 +43,7 @@ module Devise
|
|
43
43
|
|
44
44
|
# Generate a new remember token and save the record without validations.
|
45
45
|
def remember_me!
|
46
|
-
self.remember_token = friendly_token
|
46
|
+
self.remember_token = Devise.friendly_token
|
47
47
|
self.remember_created_at = Time.now.utc
|
48
48
|
save(false)
|
49
49
|
end
|
@@ -12,12 +12,15 @@ module Devise
|
|
12
12
|
|
13
13
|
include Devise::Schema
|
14
14
|
|
15
|
-
# Tell how to apply schema methods.
|
15
|
+
# Tell how to apply schema methods. This automatically converts DateTime
|
16
|
+
# to Time, since MongoMapper does not recognize the former.
|
16
17
|
def apply_schema(name, type, options={})
|
18
|
+
return unless Devise.apply_schema
|
19
|
+
type = Time if type == DateTime
|
17
20
|
key name, type, options
|
18
21
|
end
|
19
22
|
end
|
20
23
|
end
|
21
24
|
end
|
22
25
|
|
23
|
-
MongoMapper::Document::ClassMethods.send(:include, Devise::Models)
|
26
|
+
MongoMapper::Document::ClassMethods.send(:include, Devise::Models)
|
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.5.
|
4
|
+
version: 0.5.3
|
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-11-
|
13
|
+
date: 2009-11-18 00:00:00 -02:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|