devise 1.1.rc2 → 1.1.0
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 +22 -2
- data/Gemfile +7 -13
- data/Gemfile.lock +118 -0
- data/README.rdoc +15 -13
- data/app/controllers/devise/unlocks_controller.rb +0 -7
- data/app/mailers/devise/mailer.rb +7 -4
- data/app/views/devise/confirmations/new.html.erb +1 -1
- data/app/views/devise/passwords/new.html.erb +1 -1
- data/app/views/devise/unlocks/new.html.erb +1 -1
- data/lib/devise.rb +27 -9
- data/lib/devise/controllers/helpers.rb +19 -5
- data/lib/devise/controllers/internal_helpers.rb +2 -8
- data/lib/devise/encryptors/base.rb +1 -1
- data/lib/devise/encryptors/bcrypt.rb +2 -2
- data/lib/devise/failure_app.rb +6 -2
- data/lib/devise/hooks/rememberable.rb +9 -1
- data/lib/devise/mapping.rb +15 -50
- data/lib/devise/models/authenticatable.rb +8 -0
- data/lib/devise/models/confirmable.rb +10 -6
- data/lib/devise/models/database_authenticatable.rb +9 -1
- data/lib/devise/models/recoverable.rb +6 -1
- data/lib/devise/models/rememberable.rb +36 -7
- data/lib/devise/models/token_authenticatable.rb +5 -5
- data/lib/devise/models/validatable.rb +1 -1
- data/lib/devise/path_checker.rb +7 -2
- data/lib/devise/rails.rb +6 -1
- data/lib/devise/rails/routes.rb +137 -50
- data/lib/devise/rails/warden_compat.rb +16 -2
- data/lib/devise/strategies/authenticatable.rb +12 -0
- data/lib/devise/strategies/base.rb +0 -18
- data/lib/devise/strategies/rememberable.rb +9 -1
- data/lib/devise/test_helpers.rb +2 -0
- data/lib/devise/version.rb +1 -1
- data/lib/generators/active_record/devise_generator.rb +28 -0
- data/lib/generators/{devise/devise → active_record}/templates/migration.rb +4 -0
- data/lib/generators/devise/devise_generator.rb +17 -0
- data/lib/generators/devise/{install/install_generator.rb → install_generator.rb} +1 -1
- data/lib/generators/devise/orm_helpers.rb +23 -0
- data/lib/generators/devise/{install/templates → templates}/README +0 -0
- data/lib/generators/devise/{install/templates → templates}/devise.rb +20 -13
- data/lib/generators/devise/{views/views_generator.rb → views_generator.rb} +2 -2
- data/lib/generators/mongoid/devise_generator.rb +17 -0
- data/test/controllers/helpers_test.rb +9 -0
- data/test/controllers/internal_helpers_test.rb +7 -16
- data/test/controllers/url_helpers_test.rb +11 -0
- data/test/encryptors_test.rb +1 -1
- data/test/failure_app_test.rb +18 -5
- data/test/integration/authenticatable_test.rb +76 -11
- data/test/integration/confirmable_test.rb +16 -9
- data/test/integration/lockable_test.rb +11 -13
- data/test/integration/registerable_test.rb +4 -4
- data/test/integration/rememberable_test.rb +54 -1
- data/test/mapping_test.rb +10 -45
- data/test/models/confirmable_test.rb +1 -1
- data/test/models/rememberable_test.rb +108 -0
- data/test/models/validatable_test.rb +2 -4
- data/test/models_test.rb +4 -4
- data/test/rails_app/app/active_record/admin.rb +1 -1
- data/test/rails_app/app/controllers/publisher/registrations_controller.rb +2 -0
- data/test/rails_app/app/controllers/publisher/sessions_controller.rb +2 -0
- data/test/rails_app/app/controllers/users_controller.rb +5 -1
- data/test/rails_app/app/mongoid/admin.rb +1 -1
- data/test/rails_app/config/application.rb +2 -2
- data/test/rails_app/config/environments/test.rb +2 -0
- data/test/rails_app/config/initializers/devise.rb +95 -34
- data/test/rails_app/config/routes.rb +32 -14
- data/test/routes_test.rb +34 -2
- data/test/support/integration.rb +22 -6
- data/test/test_helpers_test.rb +16 -2
- metadata +24 -27
- data/lib/devise/orm/data_mapper.rb +0 -97
- data/lib/generators/devise/devise/devise_generator.rb +0 -86
- data/lib/generators/devise_generator.rb +0 -2
- data/test/orm/data_mapper.rb +0 -10
- data/test/rails_app/app/data_mapper/admin.rb +0 -12
- data/test/rails_app/app/data_mapper/shim.rb +0 -2
- data/test/rails_app/app/data_mapper/user.rb +0 -23
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
== 1.1.0
|
2
|
+
|
3
|
+
* enhancements
|
4
|
+
* Rememberable module allows user to be remembered across browsers and is enabled by default (by github.com/trevorturk)
|
5
|
+
* Rememberable module allows you to activate the period the remember me token is extended (by github.com/trevorturk)
|
6
|
+
* devise_for can now be used together with scope method in routes but with a few limitations (check the documentation)
|
7
|
+
* Support `as` or `devise_scope` in the router to specify controller access scope
|
8
|
+
* HTTP Basic Auth can now be disabled/enabled for xhr(ajax) requests using http_authenticatable_on_xhr option (by github.com/pellja)
|
9
|
+
|
10
|
+
* bug fix
|
11
|
+
* Fix a bug in Devise::TestHelpers where current_user was returning a Response object for non active accounts
|
12
|
+
* Devise should respect script_name and path_info contracts
|
13
|
+
* Fix a bug when accessing a path with (.:format) (by github.com/klacointe)
|
14
|
+
* Do not add unlock routes unless unlock strategy is email or both
|
15
|
+
* Email should be case insensitive
|
16
|
+
* Store classes as string in session, to avoid serialization and stale data issues
|
17
|
+
|
18
|
+
* deprecations
|
19
|
+
* use_default_scope is deprecated and has no effect. Use :as or :devise_scope in the router instead
|
20
|
+
|
1
21
|
== 1.1.rc2
|
2
22
|
|
3
23
|
* enhancements
|
@@ -16,7 +36,7 @@
|
|
16
36
|
* devise.mailer.user.confirmations_instructions now should be devise.mailer.confirmations_instructions.user_subject
|
17
37
|
* Generators now use Rails 3 syntax (devise:install) instead of devise_install
|
18
38
|
|
19
|
-
== 1.1.
|
39
|
+
== 1.1.rc1
|
20
40
|
|
21
41
|
* enhancements
|
22
42
|
* Rails 3 compatibility
|
@@ -29,7 +49,7 @@
|
|
29
49
|
* E-mails now use any template available in the filesystem. Easy to create multipart e-mails
|
30
50
|
* E-mails asks headers_for in the model to set the proper headers
|
31
51
|
* Allow to specify haml in devise_views
|
32
|
-
* Compatibility with
|
52
|
+
* Compatibility with Mongoid
|
33
53
|
* Make config.devise available on config/application.rb
|
34
54
|
* TokenAuthenticatable now works with HTTP Basic Auth
|
35
55
|
* Allow :unlock_strategy to be :none and add :lock_strategy which can be :failed_attempts or none. Setting those values to :none means that you want to handle lock and unlocking by yourself
|
data/Gemfile
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
|
3
|
-
|
4
|
-
gem "rails", "
|
3
|
+
if File.exist? File.expand_path('../../rails', __FILE__)
|
4
|
+
gem "rails", :path => "../rails"
|
5
|
+
else
|
6
|
+
gem "rails", :git => "git://github.com/rails/rails.git"
|
7
|
+
end
|
8
|
+
|
5
9
|
gem "warden", "0.10.7"
|
6
10
|
gem "sqlite3-ruby"
|
7
11
|
gem "webrat", "0.7.0"
|
@@ -16,14 +20,4 @@ group :mongoid do
|
|
16
20
|
gem "mongo"
|
17
21
|
gem "mongoid", :git => "git://github.com/durran/mongoid.git"
|
18
22
|
gem "bson_ext"
|
19
|
-
end
|
20
|
-
|
21
|
-
group :data_mapper do
|
22
|
-
gem 'dm-core', '~> 1.0.0', :git => 'git://github.com/datamapper/dm-core'
|
23
|
-
gem 'dm-migrations', '~> 1.0.0', :git => 'git://github.com/datamapper/dm-migrations'
|
24
|
-
gem 'dm-sqlite-adapter', '~> 1.0.0', :git => 'git://github.com/datamapper/dm-sqlite-adapter'
|
25
|
-
gem 'dm-validations', '~> 1.0.0', :git => 'git://github.com/datamapper/dm-validations'
|
26
|
-
gem 'dm-serializer', '~> 1.0.0', :git => 'git://github.com/datamapper/dm-serializer'
|
27
|
-
gem 'dm-timestamps', '~> 1.0.0', :git => 'git://github.com/datamapper/dm-timestamps'
|
28
|
-
gem 'dm-rails', '~> 1.0.0', :git => 'git://github.com/datamapper/dm-rails'
|
29
|
-
end
|
23
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
GIT
|
2
|
+
remote: git://github.com/durran/mongoid.git
|
3
|
+
revision: a5abe21
|
4
|
+
specs:
|
5
|
+
mongoid (2.0.0.beta9)
|
6
|
+
activemodel (~> 3.0.0.beta)
|
7
|
+
bson (~> 1.0.3)
|
8
|
+
mongo (~> 1.0.3)
|
9
|
+
tzinfo (~> 0.3.22)
|
10
|
+
will_paginate (~> 3.0.pre)
|
11
|
+
|
12
|
+
PATH
|
13
|
+
remote: /Users/jose/Work/github/rails
|
14
|
+
specs:
|
15
|
+
actionmailer (3.0.0.beta4)
|
16
|
+
actionpack (= 3.0.0.beta4)
|
17
|
+
mail (~> 2.2.5)
|
18
|
+
actionpack (3.0.0.beta4)
|
19
|
+
activemodel (= 3.0.0.beta4)
|
20
|
+
activesupport (= 3.0.0.beta4)
|
21
|
+
builder (~> 2.1.2)
|
22
|
+
erubis (~> 2.6.6)
|
23
|
+
i18n (~> 0.4.1)
|
24
|
+
rack (~> 1.2.1)
|
25
|
+
rack-mount (~> 0.6.9)
|
26
|
+
rack-test (~> 0.5.4)
|
27
|
+
tzinfo (~> 0.3.22)
|
28
|
+
activemodel (3.0.0.beta4)
|
29
|
+
activesupport (= 3.0.0.beta4)
|
30
|
+
builder (~> 2.1.2)
|
31
|
+
i18n (~> 0.4.1)
|
32
|
+
activerecord (3.0.0.beta4)
|
33
|
+
activemodel (= 3.0.0.beta4)
|
34
|
+
activesupport (= 3.0.0.beta4)
|
35
|
+
arel (~> 0.4.0)
|
36
|
+
tzinfo (~> 0.3.22)
|
37
|
+
activeresource (3.0.0.beta4)
|
38
|
+
activemodel (= 3.0.0.beta4)
|
39
|
+
activesupport (= 3.0.0.beta4)
|
40
|
+
activesupport (3.0.0.beta4)
|
41
|
+
rails (3.0.0.beta4)
|
42
|
+
actionmailer (= 3.0.0.beta4)
|
43
|
+
actionpack (= 3.0.0.beta4)
|
44
|
+
activerecord (= 3.0.0.beta4)
|
45
|
+
activeresource (= 3.0.0.beta4)
|
46
|
+
activesupport (= 3.0.0.beta4)
|
47
|
+
bundler (>= 1.0.0.beta.10)
|
48
|
+
railties (= 3.0.0.beta4)
|
49
|
+
railties (3.0.0.beta4)
|
50
|
+
actionpack (= 3.0.0.beta4)
|
51
|
+
activesupport (= 3.0.0.beta4)
|
52
|
+
rake (>= 0.8.3)
|
53
|
+
thor (~> 0.14.0)
|
54
|
+
|
55
|
+
GEM
|
56
|
+
remote: http://rubygems.org/
|
57
|
+
specs:
|
58
|
+
abstract (1.0.0)
|
59
|
+
arel (0.4.0)
|
60
|
+
activesupport (>= 3.0.0.beta)
|
61
|
+
bcrypt-ruby (2.1.2)
|
62
|
+
bson (1.0.4)
|
63
|
+
bson_ext (1.0.4)
|
64
|
+
builder (2.1.2)
|
65
|
+
columnize (0.3.1)
|
66
|
+
erubis (2.6.6)
|
67
|
+
abstract (>= 1.0.0)
|
68
|
+
i18n (0.4.1)
|
69
|
+
linecache (0.43)
|
70
|
+
mail (2.2.5)
|
71
|
+
activesupport (>= 2.3.6)
|
72
|
+
mime-types
|
73
|
+
treetop (>= 1.4.5)
|
74
|
+
mime-types (1.16)
|
75
|
+
mocha (0.9.8)
|
76
|
+
rake
|
77
|
+
mongo (1.0.5)
|
78
|
+
bson (>= 1.0.4)
|
79
|
+
nokogiri (1.4.2)
|
80
|
+
polyglot (0.3.1)
|
81
|
+
rack (1.2.1)
|
82
|
+
rack-mount (0.6.9)
|
83
|
+
rack (>= 1.0.0)
|
84
|
+
rack-test (0.5.4)
|
85
|
+
rack (>= 1.0)
|
86
|
+
rake (0.8.7)
|
87
|
+
ruby-debug (0.10.3)
|
88
|
+
columnize (>= 0.1)
|
89
|
+
ruby-debug-base (~> 0.10.3.0)
|
90
|
+
ruby-debug-base (0.10.3)
|
91
|
+
linecache (>= 0.3)
|
92
|
+
sqlite3-ruby (1.3.1)
|
93
|
+
thor (0.14.0)
|
94
|
+
treetop (1.4.8)
|
95
|
+
polyglot (>= 0.3.1)
|
96
|
+
tzinfo (0.3.22)
|
97
|
+
warden (0.10.7)
|
98
|
+
rack (>= 1.0.0)
|
99
|
+
webrat (0.7.0)
|
100
|
+
nokogiri (>= 1.2.0)
|
101
|
+
rack (>= 1.0)
|
102
|
+
rack-test (>= 0.5.3)
|
103
|
+
will_paginate (3.0.pre)
|
104
|
+
|
105
|
+
PLATFORMS
|
106
|
+
ruby
|
107
|
+
|
108
|
+
DEPENDENCIES
|
109
|
+
bcrypt-ruby
|
110
|
+
bson_ext
|
111
|
+
mocha
|
112
|
+
mongo
|
113
|
+
mongoid!
|
114
|
+
rails!
|
115
|
+
ruby-debug (>= 0.10.3)
|
116
|
+
sqlite3-ruby
|
117
|
+
warden (= 0.10.7)
|
118
|
+
webrat (= 0.7.0)
|
data/README.rdoc
CHANGED
@@ -22,19 +22,11 @@ Right now it's composed of 11 modules:
|
|
22
22
|
|
23
23
|
== Installation
|
24
24
|
|
25
|
-
|
25
|
+
Devise 1.1 supports Rails 3 and is NOT backward compatible. You can use the latest Rails 3 beta gem with Devise latest gem:
|
26
26
|
|
27
|
-
|
27
|
+
gem install devise --version=1.1.rc2
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
Then follow the same steps as below.
|
32
|
-
|
33
|
-
=== Rails 3 beta 3
|
34
|
-
|
35
|
-
Devise master branch now supports Rails 3 and is NOT backward compatible. You can use the latest Rails 3 beta gem with Devise latest gem:
|
36
|
-
|
37
|
-
gem install devise --version=1.1.rc1
|
29
|
+
If you want to use Rails master (from git repository) you need to use Devise from git repository and vice-versa.
|
38
30
|
|
39
31
|
After you install Devise and add it to your Gemfile, you need to run the generator:
|
40
32
|
|
@@ -46,11 +38,11 @@ The generator will install an initializer which describes ALL Devise's configura
|
|
46
38
|
|
47
39
|
Replace MODEL by the class name you want to add devise, like User, Admin, etc. This will create a model (if one does not exist) and configure it with default Devise modules. The generator will also create a migration file (if your ORM support them) and configure your routes. Continue reading this file to understand exactly what the generator produces and how to use it.
|
48
40
|
|
49
|
-
|
41
|
+
== Rails 2.3
|
50
42
|
|
51
43
|
If you want to use the Rails 2.3.x version, you should do:
|
52
44
|
|
53
|
-
gem install devise --version=1.0.
|
45
|
+
gem install devise --version=1.0.8
|
54
46
|
|
55
47
|
And please check the README at the v1.0 branch since this one is based on Rails 3:
|
56
48
|
|
@@ -283,6 +275,16 @@ Please consult their respective documentation for more information and requireme
|
|
283
275
|
|
284
276
|
Please refer to TODO file.
|
285
277
|
|
278
|
+
== Security
|
279
|
+
|
280
|
+
Needless to say, security is extremely important to Devise. If you find yourself in a possible security issue with Devise, please go through the following steps, trying to reproduce the bug:
|
281
|
+
|
282
|
+
1) Look at the source code a bit to find out whether your assumptions are correct;
|
283
|
+
2) If possible, provide a way to reproduce the bug: a small app on Github or a step-by-step to reproduce;
|
284
|
+
3) E-mail us or send a Github private message instead of using the normal issues;
|
285
|
+
|
286
|
+
Being able to reproduce the bug is the first step to fix it. Thanks for your understanding.
|
287
|
+
|
286
288
|
== Maintainers
|
287
289
|
|
288
290
|
* José Valim (http://github.com/josevalim)
|
@@ -1,5 +1,4 @@
|
|
1
1
|
class Devise::UnlocksController < ApplicationController
|
2
|
-
prepend_before_filter :ensure_email_as_unlock_strategy
|
3
2
|
prepend_before_filter :require_no_authentication
|
4
3
|
include Devise::Controllers::InternalHelpers
|
5
4
|
|
@@ -32,10 +31,4 @@ class Devise::UnlocksController < ApplicationController
|
|
32
31
|
render_with_scope :new
|
33
32
|
end
|
34
33
|
end
|
35
|
-
|
36
|
-
protected
|
37
|
-
|
38
|
-
def ensure_email_as_unlock_strategy
|
39
|
-
raise ActionController::UnknownAction unless resource_class.unlock_strategy_enabled?(:email)
|
40
|
-
end
|
41
34
|
end
|
@@ -22,14 +22,11 @@ class Devise::Mailer < ::ActionMailer::Base
|
|
22
22
|
@devise_mapping = Devise.mappings[@scope_name]
|
23
23
|
@resource = instance_variable_set("@#{@devise_mapping.name}", record)
|
24
24
|
|
25
|
-
template_path = ["devise/mailer"]
|
26
|
-
template_path.unshift "#{@devise_mapping.plural}/mailer" if self.class.scoped_views?
|
27
|
-
|
28
25
|
headers = {
|
29
26
|
:subject => translate(@devise_mapping, action),
|
30
27
|
:from => mailer_sender(@devise_mapping),
|
31
28
|
:to => record.email,
|
32
|
-
:template_path =>
|
29
|
+
:template_path => template_paths
|
33
30
|
}
|
34
31
|
|
35
32
|
headers.merge!(record.headers_for(action)) if record.respond_to?(:headers_for)
|
@@ -44,6 +41,12 @@ class Devise::Mailer < ::ActionMailer::Base
|
|
44
41
|
end
|
45
42
|
end
|
46
43
|
|
44
|
+
def template_paths
|
45
|
+
template_path = [self.class.mailer_name]
|
46
|
+
template_path.unshift "#{@devise_mapping.plural}/mailer" if self.class.scoped_views?
|
47
|
+
template_path
|
48
|
+
end
|
49
|
+
|
47
50
|
# Setup a subject doing an I18n lookup. At first, it attemps to set a subject
|
48
51
|
# based on the current mapping:
|
49
52
|
#
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<h2>Resend confirmation instructions</h2>
|
2
2
|
|
3
|
-
<%= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name)) do |f| %>
|
3
|
+
<%= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| %>
|
4
4
|
<%= devise_error_messages! %>
|
5
5
|
|
6
6
|
<p><%= f.label :email %><br />
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<h2>Forgot your password?</h2>
|
2
2
|
|
3
|
-
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name)) do |f| %>
|
3
|
+
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| %>
|
4
4
|
<%= devise_error_messages! %>
|
5
5
|
|
6
6
|
<p><%= f.label :email %><br />
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<h2>Resend unlock instructions</h2>
|
2
2
|
|
3
|
-
<%= form_for(resource, :as => resource_name, :url => unlock_path(resource_name)) do |f| %>
|
3
|
+
<%= form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post }) do |f| %>
|
4
4
|
<%= devise_error_messages! %>
|
5
5
|
|
6
6
|
<p><%= f.label :email %><br />
|
data/lib/devise.rb
CHANGED
@@ -69,6 +69,10 @@ module Devise
|
|
69
69
|
mattr_accessor :http_authenticatable
|
70
70
|
@@http_authenticatable = true
|
71
71
|
|
72
|
+
# If http authentication is used for ajax requests. True by default.
|
73
|
+
mattr_accessor :http_authenticatable_on_xhr
|
74
|
+
@@http_authenticatable_on_xhr = true
|
75
|
+
|
72
76
|
# If params authenticatable is enabled by default.
|
73
77
|
mattr_accessor :params_authenticatable
|
74
78
|
@@params_authenticatable = true
|
@@ -85,10 +89,18 @@ module Devise
|
|
85
89
|
mattr_accessor :password_length
|
86
90
|
@@password_length = 6..20
|
87
91
|
|
88
|
-
#
|
92
|
+
# The time the user will be remembered without asking for credentials again.
|
89
93
|
mattr_accessor :remember_for
|
90
94
|
@@remember_for = 2.weeks
|
91
95
|
|
96
|
+
# If true, a valid remember token can be re-used between multiple browsers.
|
97
|
+
mattr_accessor :remember_across_browsers
|
98
|
+
@@remember_across_browsers = true
|
99
|
+
|
100
|
+
# If true, extends the user's remember period when remembered via cookie.
|
101
|
+
mattr_accessor :extend_remember_period
|
102
|
+
@@extend_remember_period = false
|
103
|
+
|
92
104
|
# Time interval you can access your account before confirming your account.
|
93
105
|
mattr_accessor :confirm_within
|
94
106
|
@@confirm_within = 0.days
|
@@ -133,10 +145,6 @@ module Devise
|
|
133
145
|
mattr_accessor :unlock_in
|
134
146
|
@@unlock_in = 1.hour
|
135
147
|
|
136
|
-
# Tell when to use the default scope, if one cannot be found from routes.
|
137
|
-
mattr_accessor :use_default_scope
|
138
|
-
@@use_default_scope = false
|
139
|
-
|
140
148
|
# The default scope which is used by warden.
|
141
149
|
mattr_accessor :default_scope
|
142
150
|
@@default_scope = nil
|
@@ -149,6 +157,7 @@ module Devise
|
|
149
157
|
mattr_accessor :token_authentication_key
|
150
158
|
@@token_authentication_key = :auth_token
|
151
159
|
|
160
|
+
# Which formats should be treated as navigational.
|
152
161
|
mattr_accessor :navigational_formats
|
153
162
|
@@navigational_formats = [:html]
|
154
163
|
|
@@ -157,6 +166,17 @@ module Devise
|
|
157
166
|
@@warden_config = nil
|
158
167
|
@@warden_config_block = nil
|
159
168
|
|
169
|
+
# When set to true, signing out an user signs out all other scopes.
|
170
|
+
mattr_accessor :sign_out_all_scopes
|
171
|
+
@@sign_out_all_scopes = false
|
172
|
+
|
173
|
+
def self.use_default_scope=(*)
|
174
|
+
ActiveSupport::Deprecation.warn "config.use_default_scope is deprecated and removed from Devise. " <<
|
175
|
+
"If you are using non conventional routes in Devise, all you need to do is to pass the devise " <<
|
176
|
+
"scope in the router DSL:\n\n as :user do\n get \"sign_in\", :to => \"devise/sessions\"\n end\n\n" <<
|
177
|
+
"The method :as is also aliased to :devise_scope. Choose the one you prefer.", caller
|
178
|
+
end
|
179
|
+
|
160
180
|
# Default way to setup Devise. Run rails generate devise_install to create
|
161
181
|
# a fresh initializer with all configuration values.
|
162
182
|
def self.setup
|
@@ -174,10 +194,8 @@ module Devise
|
|
174
194
|
end
|
175
195
|
self.mailer = "Devise::Mailer"
|
176
196
|
|
177
|
-
#
|
178
|
-
|
179
|
-
# are available.
|
180
|
-
def self.add_model(resource, options)
|
197
|
+
# Small method that adds a mapping to Devise.
|
198
|
+
def self.add_mapping(resource, options)
|
181
199
|
mapping = Devise::Mapping.new(resource, options)
|
182
200
|
self.mappings[mapping.name] = mapping
|
183
201
|
self.default_scope ||= mapping.name
|
@@ -64,6 +64,16 @@ module Devise
|
|
64
64
|
warden.logout(scope)
|
65
65
|
end
|
66
66
|
|
67
|
+
# Sign out all active users or scopes. This helper is useful for signing out all roles
|
68
|
+
# in one click.
|
69
|
+
def sign_out_all_scopes
|
70
|
+
# Not "warden.logout" since we need to sign_out only devise-defined scopes.
|
71
|
+
scopes = Devise.mappings.keys
|
72
|
+
scopes.each { |scope| warden.user(scope) }
|
73
|
+
warden.raw_session.inspect
|
74
|
+
warden.logout(*scopes)
|
75
|
+
end
|
76
|
+
|
67
77
|
# Returns and delete the url stored in the session for the given scope. Useful
|
68
78
|
# for giving redirect backs after sign up:
|
69
79
|
#
|
@@ -86,13 +96,13 @@ module Devise
|
|
86
96
|
#
|
87
97
|
# map.user_root '/users', :controller => 'users' # creates user_root_path
|
88
98
|
#
|
89
|
-
# map.
|
90
|
-
#
|
99
|
+
# map.namespace :user do |user|
|
100
|
+
# user.root :controller => 'users' # creates user_root_path
|
91
101
|
# end
|
92
102
|
#
|
93
103
|
#
|
94
|
-
# If
|
95
|
-
# is not enough, you can customize it, for example:
|
104
|
+
# If the resource root path is not defined, root_path is used. However,
|
105
|
+
# if this default is not enough, you can customize it, for example:
|
96
106
|
#
|
97
107
|
# def after_sign_in_path_for(resource)
|
98
108
|
# if resource.is_a?(User) && resource.can_publish?
|
@@ -164,7 +174,11 @@ module Devise
|
|
164
174
|
# after_sign_out_path_for.
|
165
175
|
def sign_out_and_redirect(resource_or_scope)
|
166
176
|
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
167
|
-
|
177
|
+
if Devise.sign_out_all_scopes
|
178
|
+
sign_out_all_scopes
|
179
|
+
else
|
180
|
+
sign_out(scope)
|
181
|
+
end
|
168
182
|
redirect_to after_sign_out_path_for(scope)
|
169
183
|
end
|
170
184
|
|
@@ -8,7 +8,6 @@ module Devise
|
|
8
8
|
include Devise::Controllers::ScopedViews
|
9
9
|
|
10
10
|
included do
|
11
|
-
unloadable
|
12
11
|
helper DeviseHelper
|
13
12
|
|
14
13
|
helpers = %w(resource scope_name resource_name
|
@@ -38,11 +37,7 @@ module Devise
|
|
38
37
|
|
39
38
|
# Attempt to find the mapped route for devise based on request path
|
40
39
|
def devise_mapping
|
41
|
-
@devise_mapping ||=
|
42
|
-
mapping = Devise::Mapping.find_by_path(request.path)
|
43
|
-
mapping ||= Devise.mappings[Devise.default_scope] if Devise.use_default_scope
|
44
|
-
mapping
|
45
|
-
end
|
40
|
+
@devise_mapping ||= request.env["devise.mapping"]
|
46
41
|
end
|
47
42
|
|
48
43
|
# Overwrites devise_controller? to return true
|
@@ -54,8 +49,7 @@ module Devise
|
|
54
49
|
|
55
50
|
# Checks whether it's a devise mapped resource or not.
|
56
51
|
def is_devise_resource? #:nodoc:
|
57
|
-
raise ActionController::UnknownAction unless devise_mapping
|
58
|
-
devise_mapping.allowed_controllers.include?(controller_path)
|
52
|
+
raise ActionController::UnknownAction unless devise_mapping
|
59
53
|
end
|
60
54
|
|
61
55
|
# Sets the resource creating an instance variable
|