devise 1.4.5 → 1.4.7
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/.travis.yml +5 -1
- data/CHANGELOG.rdoc +13 -0
- data/app/controllers/devise/registrations_controller.rb +1 -1
- data/app/controllers/devise/sessions_controller.rb +1 -0
- data/lib/devise/controllers/helpers.rb +13 -2
- data/lib/devise/mapping.rb +2 -0
- data/lib/devise/models/trackable.rb +1 -1
- data/lib/devise/rails/routes.rb +0 -1
- data/lib/devise/strategies/authenticatable.rb +11 -11
- data/lib/devise/version.rb +1 -1
- data/lib/generators/devise/devise_generator.rb +4 -1
- data/lib/generators/templates/devise.rb +5 -6
- data/test/controllers/helpers_test.rb +5 -0
- data/test/generators/devise_generator_test.rb +6 -0
- data/test/mapping_test.rb +4 -0
- data/test/rails_app/config/routes.rb +2 -0
- metadata +4 -4
data/.travis.yml
CHANGED
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
== 1.4.7
|
2
|
+
|
3
|
+
* bug fix
|
4
|
+
* Fix backward incompatible change from 1.4.6 for those using custom controllers
|
5
|
+
|
6
|
+
== 1.4.6
|
7
|
+
|
8
|
+
* enhancements
|
9
|
+
* Allow devise_for :skip => :all
|
10
|
+
* Allow options to be passed to authenticate_user!
|
11
|
+
* Allow --skip-routes to devise generator
|
12
|
+
* Add allow_params_authentication! to make it explicit when params authentication is allowed in a controller
|
13
|
+
|
1
14
|
== 1.4.5
|
2
15
|
|
3
16
|
* bug fix
|
@@ -114,7 +114,7 @@ class Devise::RegistrationsController < ApplicationController
|
|
114
114
|
|
115
115
|
# Authenticates the current scope and gets the current resource from the session.
|
116
116
|
def authenticate_scope!
|
117
|
-
send(:"authenticate_#{resource_name}!", true)
|
117
|
+
send(:"authenticate_#{resource_name}!", :force => true)
|
118
118
|
self.resource = send(:"current_#{resource_name}")
|
119
119
|
end
|
120
120
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
class Devise::SessionsController < ApplicationController
|
2
2
|
prepend_before_filter :require_no_authentication, :only => [ :new, :create ]
|
3
|
+
prepend_before_filter :allow_params_authentication!, :only => :create
|
3
4
|
include Devise::Controllers::InternalHelpers
|
4
5
|
|
5
6
|
# GET /resource/sign_in
|
@@ -36,8 +36,14 @@ module Devise
|
|
36
36
|
mapping = mapping.name
|
37
37
|
|
38
38
|
class_eval <<-METHODS, __FILE__, __LINE__ + 1
|
39
|
-
def authenticate_#{mapping}!(
|
40
|
-
|
39
|
+
def authenticate_#{mapping}!(opts={})
|
40
|
+
if !opts.is_a?(Hash)
|
41
|
+
opts = { :force => opts }
|
42
|
+
ActiveSupport::Deprecation.warn "Passing a boolean to authenticate_#{mapping}! " \
|
43
|
+
"is deprecated, please use :force => \#{opts[:force]} instead", caller
|
44
|
+
end
|
45
|
+
opts[:scope] = :#{mapping}
|
46
|
+
warden.authenticate!(opts) if !devise_controller? || opts.delete(:force)
|
41
47
|
end
|
42
48
|
|
43
49
|
def #{mapping}_signed_in?
|
@@ -72,6 +78,11 @@ module Devise
|
|
72
78
|
false
|
73
79
|
end
|
74
80
|
|
81
|
+
# Tell warden that params authentication is allowed for that specific page.
|
82
|
+
def allow_params_authentication!
|
83
|
+
request.env["devise.allow_params_authentication"] = true
|
84
|
+
end
|
85
|
+
|
75
86
|
# Return true if the given scope is signed in session. If no scope given, return
|
76
87
|
# true if any scope is signed in. Does not run authentication hooks.
|
77
88
|
def signed_in?(scope=nil)
|
data/lib/devise/mapping.rb
CHANGED
@@ -78,6 +78,8 @@ module Devise
|
|
78
78
|
|
79
79
|
if options.has_key?(:only)
|
80
80
|
@used_routes = self.routes & Array(options[:only]).map(&singularizer)
|
81
|
+
elsif options[:skip] == :all
|
82
|
+
@used_routes = []
|
81
83
|
else
|
82
84
|
@used_routes = self.routes - Array(options[:skip]).map(&singularizer)
|
83
85
|
end
|
@@ -5,7 +5,7 @@ module Devise
|
|
5
5
|
# Track information about your user sign in. It tracks the following columns:
|
6
6
|
#
|
7
7
|
# * sign_in_count - Increased every time a sign in is made (by form, openid, oauth)
|
8
|
-
# * current_sign_in_at - A
|
8
|
+
# * current_sign_in_at - A timestamp updated when the user signs in
|
9
9
|
# * last_sign_in_at - Holds the timestamp of the previous sign in
|
10
10
|
# * current_sign_in_ip - The remote ip updated when the user sign in
|
11
11
|
# * last_sign_in_ip - Holds the remote ip of the previous sign in
|
data/lib/devise/rails/routes.rb
CHANGED
@@ -182,7 +182,6 @@ module ActionDispatch::Routing
|
|
182
182
|
options[:path_names] = (@scope[:path_names] || {}).merge(options[:path_names] || {})
|
183
183
|
options[:constraints] = (@scope[:constraints] || {}).merge(options[:constraints] || {})
|
184
184
|
options[:defaults] = (@scope[:defaults] || {}).merge(options[:defaults] || {})
|
185
|
-
|
186
185
|
@scope[:options] = (@scope[:options] || {}).merge({:format => false}) if options[:format] == false
|
187
186
|
|
188
187
|
resources.map!(&:to_sym)
|
@@ -85,17 +85,17 @@ module Devise
|
|
85
85
|
|
86
86
|
# By default, a request is valid if the controller is allowed and the VERB is POST.
|
87
87
|
def valid_request?
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
88
|
+
if env["devise.allow_params_authentication"]
|
89
|
+
true
|
90
|
+
elsif request.post? && mapping.controllers[:sessions] == params[:controller]
|
91
|
+
ActiveSupport::Deprecation.warn "It seems that you are using a custom SessionsController. " \
|
92
|
+
"In order for it to work from Devise 1.4.6 forward, you need to add the following:" \
|
93
|
+
"\n\n prepend_before_filter :allow_params_authentication!, :only => :create\n\n" \
|
94
|
+
"This will ensure your controller can authenticate from params for the create action.", caller
|
95
|
+
true
|
96
|
+
else
|
97
|
+
false
|
98
|
+
end
|
99
99
|
end
|
100
100
|
|
101
101
|
# If the request is valid, finally check if params_auth_hash returns a hash.
|
data/lib/devise/version.rb
CHANGED
@@ -9,9 +9,12 @@ module Devise
|
|
9
9
|
|
10
10
|
hook_for :orm
|
11
11
|
|
12
|
+
class_option :routes, :desc => "Generate routes", :type => :boolean, :default => true
|
13
|
+
|
12
14
|
def add_devise_routes
|
13
15
|
devise_route = "devise_for :#{plural_name}"
|
14
|
-
devise_route
|
16
|
+
devise_route << %Q(, :class_name => "#{class_name}") if class_name.include?("::")
|
17
|
+
devise_route << %Q(, :skip => :all) unless options.routes?
|
15
18
|
route devise_route
|
16
19
|
end
|
17
20
|
end
|
@@ -72,12 +72,11 @@ Devise.setup do |config|
|
|
72
72
|
# config.pepper = <%= SecureRandom.hex(64).inspect %>
|
73
73
|
|
74
74
|
# ==> Configuration for :confirmable
|
75
|
-
#
|
76
|
-
#
|
77
|
-
#
|
78
|
-
#
|
79
|
-
#
|
80
|
-
# (ie 2 days).
|
75
|
+
# A period that the user is allowed to access the website even without
|
76
|
+
# confirming his account. For instance, if set to 2.days, the user will be
|
77
|
+
# able to access the website for two days without confirming his account,
|
78
|
+
# access will be blocked just in the third day. Default is 0.days, meaning
|
79
|
+
# the user cannot access the website without confirming his account.
|
81
80
|
# config.confirm_within = 2.days
|
82
81
|
|
83
82
|
# Defines which key will be used when confirming an account
|
@@ -45,6 +45,11 @@ class ControllerAuthenticatableTest < ActionController::TestCase
|
|
45
45
|
@controller.authenticate_user!
|
46
46
|
end
|
47
47
|
|
48
|
+
test 'proxy authenticate_user! options to authenticate with user scope' do
|
49
|
+
@mock_warden.expects(:authenticate!).with(:scope => :user, :recall => "foo")
|
50
|
+
@controller.authenticate_user!(:recall => "foo")
|
51
|
+
end
|
52
|
+
|
48
53
|
test 'proxy authenticate_admin! to authenticate with admin scope' do
|
49
54
|
@mock_warden.expects(:authenticate!).with(:scope => :admin)
|
50
55
|
@controller.authenticate_admin!
|
@@ -22,6 +22,12 @@ class DeviseGeneratorTest < Rails::Generators::TestCase
|
|
22
22
|
assert_file "config/routes.rb", match
|
23
23
|
end
|
24
24
|
|
25
|
+
test "route generation with skip routes" do
|
26
|
+
run_generator %w(monster name:string --skip-routes)
|
27
|
+
match = /devise_for :monsters, :skip => :all/
|
28
|
+
assert_file "config/routes.rb", match
|
29
|
+
end
|
30
|
+
|
25
31
|
def copy_routes
|
26
32
|
routes = File.expand_path("../../rails_app/config/routes.rb", __FILE__)
|
27
33
|
destination = File.join(destination_root, "config")
|
data/test/mapping_test.rb
CHANGED
@@ -31,6 +31,10 @@ class MappingTest < ActiveSupport::TestCase
|
|
31
31
|
assert_equal "admin_area", Devise.mappings[:admin].path
|
32
32
|
end
|
33
33
|
|
34
|
+
test 'allows to skip all routes' do
|
35
|
+
assert_equal [], Devise.mappings[:skip_admin].used_routes
|
36
|
+
end
|
37
|
+
|
34
38
|
test 'sign_out_via defaults to :get' do
|
35
39
|
assert_equal :get, Devise.mappings[:user].sign_out_via
|
36
40
|
end
|
@@ -50,6 +50,8 @@ Rails.application.routes.draw do
|
|
50
50
|
constraints(:host => /192\.168\.1\.\d\d\d/) do
|
51
51
|
devise_for :homebase_admin, :class_name => "Admin", :path => "homebase"
|
52
52
|
end
|
53
|
+
|
54
|
+
devise_for :skip_admin, :class_name => "Admin", :skip => :all
|
53
55
|
|
54
56
|
# Routes for format=false testing
|
55
57
|
devise_for :htmlonly_admin, :class_name => "Admin", :skip => [:confirmations, :unlocks], :path => "htmlonly_admin", :format => false, :skip_helpers => [:confirmations, :unlocks]
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 1.4.
|
9
|
+
- 7
|
10
|
+
version: 1.4.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Jos\xC3\xA9 Valim"
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-09-
|
19
|
+
date: 2011-09-22 00:00:00 +02:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|