loyal_devise 2.1.2 → 2.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. data/.gitignore +2 -0
  2. data/.travis.yml +14 -9
  3. data/.yardopts +9 -0
  4. data/CHANGELOG.rdoc +60 -5
  5. data/CONTRIBUTING.md +4 -2
  6. data/Gemfile +7 -7
  7. data/Gemfile.lock +107 -101
  8. data/MIT-LICENSE +1 -1
  9. data/README.md +110 -48
  10. data/Rakefile +1 -0
  11. data/app/controllers/devise/confirmations_controller.rb +2 -4
  12. data/app/controllers/devise/omniauth_callbacks_controller.rb +0 -1
  13. data/app/controllers/devise/passwords_controller.rb +16 -5
  14. data/app/controllers/devise/registrations_controller.rb +13 -7
  15. data/app/controllers/devise/sessions_controller.rb +6 -6
  16. data/app/controllers/devise/unlocks_controller.rb +3 -4
  17. data/app/controllers/devise_controller.rb +12 -33
  18. data/app/helpers/devise_helper.rb +0 -1
  19. data/app/mailers/devise/mailer.rb +7 -8
  20. data/app/views/devise/mailer/confirmation_instructions.html.erb +1 -1
  21. data/app/views/devise/mailer/reset_password_instructions.html.erb +1 -1
  22. data/app/views/devise/registrations/edit.html.erb +5 -1
  23. data/config/locales/en.yml +48 -48
  24. data/devise.gemspec +6 -6
  25. data/devise.png +0 -0
  26. data/gemfiles/{Gemfile.rails-3.1.x → Gemfile.rails-3.2.x} +8 -12
  27. data/gemfiles/Gemfile.rails-3.2.x.lock +156 -0
  28. data/lib/devise.rb +34 -11
  29. data/lib/devise/controllers/helpers.rb +33 -7
  30. data/lib/devise/controllers/rememberable.rb +6 -3
  31. data/lib/devise/controllers/scoped_views.rb +1 -2
  32. data/lib/devise/controllers/url_helpers.rb +0 -1
  33. data/lib/devise/delegator.rb +0 -1
  34. data/lib/devise/failure_app.rb +8 -2
  35. data/lib/devise/hooks/activatable.rb +1 -2
  36. data/lib/devise/hooks/forgetable.rb +0 -1
  37. data/lib/devise/hooks/lockable.rb +1 -2
  38. data/lib/devise/hooks/rememberable.rb +1 -2
  39. data/lib/devise/hooks/timeoutable.rb +0 -1
  40. data/lib/devise/hooks/trackable.rb +0 -1
  41. data/lib/devise/mailers/helpers.rb +18 -14
  42. data/lib/devise/mapping.rb +6 -7
  43. data/lib/devise/models.rb +0 -1
  44. data/lib/devise/models/authenticatable.rb +50 -27
  45. data/lib/devise/models/confirmable.rb +37 -16
  46. data/lib/devise/models/database_authenticatable.rb +17 -3
  47. data/lib/devise/models/lockable.rb +1 -2
  48. data/lib/devise/models/omniauthable.rb +1 -2
  49. data/lib/devise/models/recoverable.rb +10 -6
  50. data/lib/devise/models/registerable.rb +0 -1
  51. data/lib/devise/models/rememberable.rb +1 -2
  52. data/lib/devise/models/timeoutable.rb +1 -2
  53. data/lib/devise/models/token_authenticatable.rb +0 -1
  54. data/lib/devise/models/trackable.rb +0 -1
  55. data/lib/devise/models/validatable.rb +0 -1
  56. data/lib/devise/modules.rb +1 -2
  57. data/lib/devise/omniauth.rb +0 -1
  58. data/lib/devise/omniauth/config.rb +0 -1
  59. data/lib/devise/omniauth/url_helpers.rb +0 -1
  60. data/lib/devise/orm/active_record.rb +1 -2
  61. data/lib/devise/orm/mongoid.rb +1 -2
  62. data/lib/devise/{param_filter.rb → parameter_filter.rb} +10 -12
  63. data/lib/devise/parameter_sanitizer.rb +59 -0
  64. data/lib/devise/rails.rb +0 -1
  65. data/lib/devise/rails/routes.rb +22 -18
  66. data/lib/devise/rails/warden_compat.rb +0 -30
  67. data/lib/devise/strategies/authenticatable.rb +8 -6
  68. data/lib/devise/strategies/base.rb +1 -2
  69. data/lib/devise/strategies/database_authenticatable.rb +1 -2
  70. data/lib/devise/strategies/rememberable.rb +1 -2
  71. data/lib/devise/strategies/token_authenticatable.rb +38 -4
  72. data/lib/devise/test_helpers.rb +0 -1
  73. data/lib/devise/time_inflector.rb +1 -2
  74. data/lib/devise/version.rb +1 -2
  75. data/lib/generators/active_record/devise_generator.rb +1 -5
  76. data/lib/generators/active_record/templates/migration.rb +0 -1
  77. data/lib/generators/active_record/templates/migration_existing.rb +0 -1
  78. data/lib/generators/devise/devise_generator.rb +0 -1
  79. data/lib/generators/devise/install_generator.rb +0 -1
  80. data/lib/generators/devise/orm_helpers.rb +1 -2
  81. data/lib/generators/devise/views_generator.rb +8 -3
  82. data/lib/generators/mongoid/devise_generator.rb +1 -2
  83. data/lib/generators/templates/README +1 -1
  84. data/lib/generators/templates/devise.rb +10 -5
  85. data/lib/generators/templates/markerb/confirmation_instructions.markerb +1 -1
  86. data/lib/generators/templates/simple_form_for/confirmations/new.html.erb +1 -0
  87. data/lib/generators/templates/simple_form_for/registrations/edit.html.erb +6 -1
  88. data/lib/generators/templates/simple_form_for/unlocks/new.html.erb +1 -0
  89. data/loyal_devise.gemspec +27 -0
  90. data/test/controllers/custom_strategy_test.rb +0 -1
  91. data/test/controllers/helpers_test.rb +0 -1
  92. data/test/controllers/internal_helpers_test.rb +13 -4
  93. data/test/controllers/passwords_controller_test.rb +32 -0
  94. data/test/controllers/sessions_controller_test.rb +28 -1
  95. data/test/controllers/url_helpers_test.rb +0 -1
  96. data/test/delegator_test.rb +0 -1
  97. data/test/devise_test.rb +12 -2
  98. data/test/failure_app_test.rb +3 -4
  99. data/test/generators/active_record_generator_test.rb +1 -4
  100. data/test/generators/devise_generator_test.rb +0 -1
  101. data/test/generators/install_generator_test.rb +0 -1
  102. data/test/generators/mongoid_generator_test.rb +0 -1
  103. data/test/generators/views_generator_test.rb +16 -2
  104. data/test/helpers/devise_helper_test.rb +1 -2
  105. data/test/integration/authenticatable_test.rb +92 -27
  106. data/test/integration/confirmable_test.rb +7 -7
  107. data/test/integration/database_authenticatable_test.rb +8 -7
  108. data/test/integration/http_authenticatable_test.rb +19 -2
  109. data/test/integration/lockable_test.rb +1 -2
  110. data/test/integration/omniauthable_test.rb +2 -3
  111. data/test/integration/recoverable_test.rb +40 -12
  112. data/test/integration/registerable_test.rb +17 -14
  113. data/test/integration/rememberable_test.rb +16 -10
  114. data/test/integration/timeoutable_test.rb +11 -2
  115. data/test/integration/token_authenticatable_test.rb +45 -2
  116. data/test/integration/trackable_test.rb +1 -2
  117. data/test/mailers/confirmation_instructions_test.rb +11 -3
  118. data/test/mailers/reset_password_instructions_test.rb +11 -3
  119. data/test/mailers/unlock_instructions_test.rb +11 -2
  120. data/test/mapping_test.rb +0 -1
  121. data/test/models/authenticatable_test.rb +6 -1
  122. data/test/models/confirmable_test.rb +53 -2
  123. data/test/models/database_authenticatable_test.rb +57 -21
  124. data/test/models/lockable_test.rb +1 -2
  125. data/test/models/omniauthable_test.rb +0 -1
  126. data/test/models/recoverable_test.rb +21 -5
  127. data/test/models/registerable_test.rb +0 -1
  128. data/test/models/rememberable_test.rb +4 -4
  129. data/test/models/serializable_test.rb +8 -8
  130. data/test/models/timeoutable_test.rb +0 -1
  131. data/test/models/token_authenticatable_test.rb +0 -1
  132. data/test/models/trackable_test.rb +0 -1
  133. data/test/models/validatable_test.rb +16 -6
  134. data/test/models_test.rb +7 -24
  135. data/test/omniauth/config_test.rb +1 -2
  136. data/test/omniauth/url_helpers_test.rb +4 -2
  137. data/test/orm/active_record.rb +1 -1
  138. data/test/orm/mongoid.rb +2 -4
  139. data/test/parameter_sanitizer_test.rb +51 -0
  140. data/test/rails_app/Rakefile +0 -4
  141. data/test/rails_app/app/active_record/admin.rb +0 -1
  142. data/test/rails_app/app/active_record/shim.rb +1 -2
  143. data/test/rails_app/app/active_record/user.rb +0 -1
  144. data/test/rails_app/app/controllers/admins/sessions_controller.rb +1 -2
  145. data/test/rails_app/app/controllers/admins_controller.rb +0 -1
  146. data/test/rails_app/app/controllers/application_controller.rb +1 -1
  147. data/test/rails_app/app/controllers/home_controller.rb +0 -1
  148. data/test/rails_app/app/controllers/publisher/registrations_controller.rb +1 -2
  149. data/test/rails_app/app/controllers/publisher/sessions_controller.rb +1 -2
  150. data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +1 -2
  151. data/test/rails_app/app/controllers/users_controller.rb +8 -1
  152. data/test/rails_app/app/helpers/application_helper.rb +0 -1
  153. data/test/rails_app/app/mailers/users/mailer.rb +4 -1
  154. data/test/rails_app/app/mongoid/admin.rb +4 -3
  155. data/test/rails_app/app/mongoid/shim.rb +3 -5
  156. data/test/rails_app/app/mongoid/user.rb +2 -3
  157. data/test/rails_app/app/views/users/edit_form.html.erb +1 -0
  158. data/test/rails_app/bin/bundle +3 -0
  159. data/test/rails_app/bin/rails +4 -0
  160. data/test/rails_app/bin/rake +4 -0
  161. data/test/rails_app/config/application.rb +1 -3
  162. data/test/rails_app/config/boot.rb +3 -4
  163. data/test/rails_app/config/environment.rb +2 -3
  164. data/test/rails_app/config/environments/development.rb +23 -8
  165. data/test/rails_app/config/environments/production.rb +68 -18
  166. data/test/rails_app/config/environments/test.rb +18 -16
  167. data/test/rails_app/config/initializers/backtrace_silencers.rb +0 -1
  168. data/test/rails_app/config/initializers/devise.rb +0 -1
  169. data/test/rails_app/config/initializers/inflections.rb +0 -1
  170. data/test/rails_app/config/initializers/secret_token.rb +8 -3
  171. data/test/rails_app/config/initializers/session_store.rb +1 -0
  172. data/test/rails_app/config/routes.rb +20 -17
  173. data/test/rails_app/db/migrate/20100401102949_create_tables.rb +0 -1
  174. data/test/rails_app/db/schema.rb +0 -1
  175. data/test/rails_app/lib/shared_admin.rb +0 -1
  176. data/test/rails_app/lib/shared_user.rb +0 -2
  177. data/test/routes_test.rb +22 -21
  178. data/test/support/assertions.rb +0 -1
  179. data/test/support/helpers.rb +1 -2
  180. data/test/support/integration.rb +0 -1
  181. data/test/support/webrat/integrations/rails.rb +0 -1
  182. data/test/test_helper.rb +8 -2
  183. data/test/test_helpers_test.rb +0 -1
  184. data/test/test_models.rb +26 -0
  185. metadata +65 -27
  186. data/gemfiles/Gemfile.rails-3.1.x.lock +0 -167
  187. data/test/indifferent_hash.rb +0 -34
  188. data/test/rails_app/script/rails +0 -10
@@ -3,24 +3,24 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
  require "devise/version"
4
4
 
5
5
  Gem::Specification.new do |s|
6
- s.name = "loyal_devise"
6
+ s.name = "devise"
7
7
  s.version = Devise::VERSION.dup
8
8
  s.platform = Gem::Platform::RUBY
9
+ s.licenses = ["MIT"]
9
10
  s.summary = "Flexible authentication solution for Rails with Warden"
10
11
  s.email = "contact@plataformatec.com.br"
11
- s.homepage = "http://github.com/blogsoso/devise"
12
+ s.homepage = "http://github.com/plataformatec/devise"
12
13
  s.description = "Flexible authentication solution for Rails with Warden"
13
14
  s.authors = ['José Valim', 'Carlos Antônio']
14
15
 
15
- # s.rubyforge_project = "devise"
16
+ s.rubyforge_project = "devise"
16
17
 
17
18
  s.files = `git ls-files`.split("\n")
18
19
  s.test_files = `git ls-files -- test/*`.split("\n")
19
20
  s.require_paths = ["lib"]
20
21
 
21
- s.add_dependency("loyal_warden", "~> 2.0.0")
22
- # s.add_dependency("warden", "~> 2.0.0")
22
+ s.add_dependency("warden", "~> 1.2.1")
23
23
  s.add_dependency("orm_adapter", "~> 0.1")
24
24
  s.add_dependency("bcrypt-ruby", "~> 3.0")
25
- # s.add_dependency("railties", "~> 3.1")
25
+ s.add_dependency("railties", ">= 3.2.6", "< 5")
26
26
  end
Binary file
@@ -1,8 +1,8 @@
1
- source "http://rubygems.org"
1
+ source "https://rubygems.org"
2
2
 
3
- gem "loyal_devise", :path => ".."
3
+ gemspec :path => '..'
4
4
 
5
- gem "rails", "~> 3.1.0"
5
+ gem "rails", "~> 3.2.6"
6
6
  gem "omniauth", "~> 1.0.0"
7
7
  gem "omniauth-oauth2", "~> 1.0.0"
8
8
  gem "rdoc"
@@ -10,12 +10,8 @@ gem "rdoc"
10
10
  group :test do
11
11
  gem "omniauth-facebook"
12
12
  gem "omniauth-openid", "~> 1.0.1"
13
- gem "webrat", "0.7.2", :require => false
14
- gem "mocha", :require => false
15
-
16
- platforms :mri_18 do
17
- gem "ruby-debug", ">= 0.10.3"
18
- end
13
+ gem "webrat", "0.7.3", :require => false
14
+ gem "mocha", "~> 0.13.1", :require => false
19
15
  end
20
16
 
21
17
  platforms :jruby do
@@ -26,10 +22,10 @@ end
26
22
 
27
23
  platforms :ruby do
28
24
  gem "sqlite3"
25
+ end
29
26
 
27
+ platforms :mri_19, :mri_20 do
30
28
  group :mongoid do
31
- gem "mongo", "~> 1.3.0"
32
- gem "mongoid", "~> 2.0"
33
- gem "bson_ext", "~> 1.3.0"
29
+ gem "mongoid", "~> 3.0"
34
30
  end
35
31
  end
@@ -0,0 +1,156 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ devise (3.0.0.rc)
5
+ bcrypt-ruby (~> 3.0)
6
+ orm_adapter (~> 0.1)
7
+ railties (>= 3.2.6, < 5)
8
+ warden (~> 1.2.1)
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ actionmailer (3.2.13)
14
+ actionpack (= 3.2.13)
15
+ mail (~> 2.5.3)
16
+ actionpack (3.2.13)
17
+ activemodel (= 3.2.13)
18
+ activesupport (= 3.2.13)
19
+ builder (~> 3.0.0)
20
+ erubis (~> 2.7.0)
21
+ journey (~> 1.0.4)
22
+ rack (~> 1.4.5)
23
+ rack-cache (~> 1.2)
24
+ rack-test (~> 0.6.1)
25
+ sprockets (~> 2.2.1)
26
+ activemodel (3.2.13)
27
+ activesupport (= 3.2.13)
28
+ builder (~> 3.0.0)
29
+ activerecord (3.2.13)
30
+ activemodel (= 3.2.13)
31
+ activesupport (= 3.2.13)
32
+ arel (~> 3.0.2)
33
+ tzinfo (~> 0.3.29)
34
+ activeresource (3.2.13)
35
+ activemodel (= 3.2.13)
36
+ activesupport (= 3.2.13)
37
+ activesupport (3.2.13)
38
+ i18n (= 0.6.1)
39
+ multi_json (~> 1.0)
40
+ arel (3.0.2)
41
+ bcrypt-ruby (3.0.1)
42
+ builder (3.0.4)
43
+ erubis (2.7.0)
44
+ faraday (0.8.7)
45
+ multipart-post (~> 1.1)
46
+ hashie (1.2.0)
47
+ hike (1.2.2)
48
+ httpauth (0.2.0)
49
+ i18n (0.6.1)
50
+ journey (1.0.4)
51
+ json (1.7.7)
52
+ jwt (0.1.8)
53
+ multi_json (>= 1.5)
54
+ mail (2.5.3)
55
+ i18n (>= 0.4.0)
56
+ mime-types (~> 1.16)
57
+ treetop (~> 1.4.8)
58
+ metaclass (0.0.1)
59
+ mime-types (1.23)
60
+ mocha (0.13.3)
61
+ metaclass (~> 0.0.1)
62
+ mongoid (3.1.3)
63
+ activemodel (~> 3.2)
64
+ moped (~> 1.4.2)
65
+ origin (~> 1.0)
66
+ tzinfo (~> 0.3.22)
67
+ moped (1.4.5)
68
+ multi_json (1.7.3)
69
+ multipart-post (1.2.0)
70
+ nokogiri (1.5.9)
71
+ oauth2 (0.8.1)
72
+ faraday (~> 0.8)
73
+ httpauth (~> 0.1)
74
+ jwt (~> 0.1.4)
75
+ multi_json (~> 1.0)
76
+ rack (~> 1.2)
77
+ omniauth (1.0.3)
78
+ hashie (~> 1.2)
79
+ rack
80
+ omniauth-facebook (1.4.0)
81
+ omniauth-oauth2 (~> 1.0.2)
82
+ omniauth-oauth2 (1.0.3)
83
+ oauth2 (~> 0.8.0)
84
+ omniauth (~> 1.0)
85
+ omniauth-openid (1.0.1)
86
+ omniauth (~> 1.0)
87
+ rack-openid (~> 1.3.1)
88
+ origin (1.1.0)
89
+ orm_adapter (0.4.0)
90
+ polyglot (0.3.3)
91
+ rack (1.4.5)
92
+ rack-cache (1.2)
93
+ rack (>= 0.4)
94
+ rack-openid (1.3.1)
95
+ rack (>= 1.1.0)
96
+ ruby-openid (>= 2.1.8)
97
+ rack-ssl (1.3.3)
98
+ rack
99
+ rack-test (0.6.2)
100
+ rack (>= 1.0)
101
+ rails (3.2.13)
102
+ actionmailer (= 3.2.13)
103
+ actionpack (= 3.2.13)
104
+ activerecord (= 3.2.13)
105
+ activeresource (= 3.2.13)
106
+ activesupport (= 3.2.13)
107
+ bundler (~> 1.0)
108
+ railties (= 3.2.13)
109
+ railties (3.2.13)
110
+ actionpack (= 3.2.13)
111
+ activesupport (= 3.2.13)
112
+ rack-ssl (~> 1.3.2)
113
+ rake (>= 0.8.7)
114
+ rdoc (~> 3.4)
115
+ thor (>= 0.14.6, < 2.0)
116
+ rake (10.0.4)
117
+ rdoc (3.12.2)
118
+ json (~> 1.4)
119
+ ruby-openid (2.2.3)
120
+ sprockets (2.2.2)
121
+ hike (~> 1.2)
122
+ multi_json (~> 1.0)
123
+ rack (~> 1.0)
124
+ tilt (~> 1.1, != 1.3.0)
125
+ sqlite3 (1.3.7)
126
+ thor (0.18.1)
127
+ tilt (1.4.0)
128
+ treetop (1.4.12)
129
+ polyglot
130
+ polyglot (>= 0.3.1)
131
+ tzinfo (0.3.37)
132
+ warden (1.2.1)
133
+ rack (>= 1.0)
134
+ webrat (0.7.3)
135
+ nokogiri (>= 1.2.0)
136
+ rack (>= 1.0)
137
+ rack-test (>= 0.5.3)
138
+
139
+ PLATFORMS
140
+ ruby
141
+
142
+ DEPENDENCIES
143
+ activerecord-jdbc-adapter
144
+ activerecord-jdbcsqlite3-adapter
145
+ devise!
146
+ jruby-openssl
147
+ mocha (~> 0.13.1)
148
+ mongoid (~> 3.0)
149
+ omniauth (~> 1.0.0)
150
+ omniauth-facebook
151
+ omniauth-oauth2 (~> 1.0.0)
152
+ omniauth-openid (~> 1.0.1)
153
+ rails (~> 3.2.6)
154
+ rdoc
155
+ sqlite3
156
+ webrat (= 0.7.3)
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  require 'rails'
3
2
  require 'active_support/core_ext/numeric/time'
4
3
  require 'active_support/dependencies'
@@ -7,12 +6,14 @@ require 'set'
7
6
  require 'securerandom'
8
7
 
9
8
  module Devise
10
- autoload :Delegator, 'devise/delegator'
11
- autoload :FailureApp, 'devise/failure_app'
12
- autoload :OmniAuth, 'devise/omniauth'
13
- autoload :ParamFilter, 'devise/param_filter'
14
- autoload :TestHelpers, 'devise/test_helpers'
15
- autoload :TimeInflector, 'devise/time_inflector'
9
+ autoload :Delegator, 'devise/delegator'
10
+ autoload :FailureApp, 'devise/failure_app'
11
+ autoload :OmniAuth, 'devise/omniauth'
12
+ autoload :ParameterFilter, 'devise/parameter_filter'
13
+ autoload :BaseSanitizer, 'devise/parameter_sanitizer'
14
+ autoload :ParameterSanitizer, 'devise/parameter_sanitizer'
15
+ autoload :TestHelpers, 'devise/test_helpers'
16
+ autoload :TimeInflector, 'devise/time_inflector'
16
17
 
17
18
  module Controllers
18
19
  autoload :Helpers, 'devise/controllers/helpers'
@@ -44,7 +45,7 @@ module Devise
44
45
  # True values used to check params
45
46
  TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE']
46
47
 
47
- # Custom domain for cookies. Not set by default
48
+ # Custom domain or key for cookies. Not set by default
48
49
  mattr_accessor :rememberable_options
49
50
  @@rememberable_options = {}
50
51
 
@@ -52,6 +53,10 @@ module Devise
52
53
  mattr_accessor :stretches
53
54
  @@stretches = 10
54
55
 
56
+ # The default key used when authenticating over http auth.
57
+ mattr_accessor :http_authentication_key
58
+ @@http_authentication_key = nil
59
+
55
60
  # Keys used when authenticating a user.
56
61
  mattr_accessor :authentication_keys
57
62
  @@authentication_keys = [ :email ]
@@ -88,7 +93,7 @@ module Devise
88
93
  # an one (and only one) @ exists in the given string. This is mainly
89
94
  # to give user feedback and not to assert the e-mail validity.
90
95
  mattr_accessor :email_regexp
91
- @@email_regexp = /\A[^@]+@([^@\.]+\.)+[^@\.]+\z/
96
+ @@email_regexp = /\A[^@\s]+@([^@\s]+\.)+[^@\s]+\z/
92
97
 
93
98
  # Range validation for password length
94
99
  mattr_accessor :password_length
@@ -103,6 +108,7 @@ module Devise
103
108
  @@extend_remember_period = false
104
109
 
105
110
  # Time interval you can access your account before confirming your account.
111
+ # nil - allows unconfirmed access for unlimited time
106
112
  mattr_accessor :allow_unconfirmed_access_for
107
113
  @@allow_unconfirmed_access_for = 0.days
108
114
 
@@ -200,6 +206,12 @@ module Devise
200
206
  mattr_accessor :parent_controller
201
207
  @@parent_controller = "ApplicationController"
202
208
 
209
+ # The parent mailer all Devise mailers inherit from.
210
+ # Defaults to ActionMailer::Base. This should be set early
211
+ # in the initialization process and should be set to a string.
212
+ mattr_accessor :parent_mailer
213
+ @@parent_mailer = "ActionMailer::Base"
214
+
203
215
  # The router Devise should use to generate routes. Defaults
204
216
  # to :main_app. Should be overriden by engines in order
205
217
  # to provide custom routes.
@@ -305,7 +317,7 @@ module Devise
305
317
  # == Options:
306
318
  #
307
319
  # +model+ - String representing the load path to a custom *model* for this module (to autoload.)
308
- # +controller+ - Symbol representing the name of an exisiting or custom *controller* for this module.
320
+ # +controller+ - Symbol representing the name of an existing or custom *controller* for this module.
309
321
  # +route+ - Symbol representing the named *route* helper for this module.
310
322
  # +strategy+ - Symbol representing if this module got a custom *strategy*.
311
323
  #
@@ -415,6 +427,17 @@ module Devise
415
427
 
416
428
  Devise.mappings.each_value do |mapping|
417
429
  warden_config.scope_defaults mapping.name, :strategies => mapping.strategies
430
+
431
+ warden_config.serialize_into_session(mapping.name) do |record|
432
+ mapping.to.serialize_into_session(record)
433
+ end
434
+
435
+ warden_config.serialize_from_session(mapping.name) do |key|
436
+ # Previous versions contained an additional entry at the beginning of
437
+ # key with the record's class name.
438
+ args = key[-2, 2]
439
+ mapping.to.serialize_from_session(*args)
440
+ end
418
441
  end
419
442
 
420
443
  @@warden_config_block.try :call, Devise.warden_config
@@ -422,7 +445,7 @@ module Devise
422
445
  end
423
446
  end
424
447
 
425
- # Generate a friendly string randomically to be used as token.
448
+ # Generate a friendly string randomly to be used as token.
426
449
  def self.friendly_token
427
450
  SecureRandom.base64(15).tr('+/=lIO0', 'pqrsxyz')
428
451
  end
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  module Devise
3
2
  module Controllers
4
3
  # Those helpers are convenience methods added to ApplicationController.
@@ -81,6 +80,17 @@ module Devise
81
80
  is_a?(DeviseController)
82
81
  end
83
82
 
83
+ # Setup a param sanitizer to filter parameters using strong_parameters. See
84
+ # lib/devise/parameter_sanitizer.rb for more info. Override this
85
+ # method in your application controller to use your own parameter sanitizer.
86
+ def devise_parameter_sanitizer
87
+ @devise_parameter_sanitizer ||= if defined?(ActionController::StrongParameters)
88
+ Devise::ParameterSanitizer.new(resource_class, resource_name, params)
89
+ else
90
+ Devise::BaseSanitizer.new(resource_class, resource_name, params)
91
+ end
92
+ end
93
+
84
94
  # Tell warden that params authentication is allowed for that specific page.
85
95
  def allow_params_authentication!
86
96
  request.env["devise.allow_params_authentication"] = true
@@ -163,8 +173,8 @@ module Devise
163
173
  users.any?
164
174
  end
165
175
 
166
- # Returns and delete the url stored in the session for the given scope. Useful
167
- # for giving redirect backs after sign up:
176
+ # Returns and delete (if it's navigational format) the url stored in the session for
177
+ # the given scope. Useful for giving redirect backs after sign up:
168
178
  #
169
179
  # Example:
170
180
  #
@@ -172,7 +182,12 @@ module Devise
172
182
  #
173
183
  def stored_location_for(resource_or_scope)
174
184
  scope = Devise::Mapping.find_scope!(resource_or_scope)
175
- session.delete("#{scope}_return_to")
185
+
186
+ if is_navigational_format?
187
+ session.delete("#{scope}_return_to")
188
+ else
189
+ session["#{scope}_return_to"]
190
+ end
176
191
  end
177
192
 
178
193
  # The scope root url to be used when he's signed in. By default, it first
@@ -257,12 +272,23 @@ module Devise
257
272
  # Overwrite Rails' handle unverified request to sign out all scopes,
258
273
  # clear run strategies and remove cached variables.
259
274
  def handle_unverified_request
260
- sign_out_all_scopes(false)
261
- request.env["devise.skip_storage"] = true
262
- expire_devise_cached_variables!
275
+ if sign_in?
276
+ sign_out_all_scopes(false)
277
+ request.env["devise.skip_storage"] = true
278
+ expire_devise_cached_variables!
279
+ end
280
+
263
281
  super # call the default behaviour which resets the session
264
282
  end
265
283
 
284
+ def request_format
285
+ @request_format ||= request.format.try(:ref)
286
+ end
287
+
288
+ def is_navigational_format?
289
+ Devise.navigational_formats.include?(request_format)
290
+ end
291
+
266
292
  private
267
293
 
268
294
  def expire_devise_cached_variables!
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  module Devise
3
2
  module Controllers
4
3
  # A module that may be optionally included in a controller in order
@@ -24,14 +23,14 @@ module Devise
24
23
  def remember_me(resource)
25
24
  scope = Devise::Mapping.find_scope!(resource)
26
25
  resource.remember_me!(resource.extend_remember_period)
27
- cookies.signed["remember_#{scope}_token"] = remember_cookie_values(resource)
26
+ cookies.signed[remember_key(resource, scope)] = remember_cookie_values(resource)
28
27
  end
29
28
 
30
29
  # Forgets the given resource by deleting a cookie
31
30
  def forget_me(resource)
32
31
  scope = Devise::Mapping.find_scope!(resource)
33
32
  resource.forget_me!
34
- cookies.delete("remember_#{scope}_token", forget_cookie_values(resource))
33
+ cookies.delete(remember_key(resource, scope), forget_cookie_values(resource))
35
34
  end
36
35
 
37
36
  protected
@@ -48,6 +47,10 @@ module Devise
48
47
  :expires => resource.remember_expires_at
49
48
  )
50
49
  end
50
+
51
+ def remember_key(resource, scope)
52
+ resource.rememberable_options.fetch(:key, "remember_#{scope}_token")
53
+ end
51
54
  end
52
55
  end
53
56
  end
@@ -1,4 +1,3 @@
1
- # -*- encoding : utf-8 -*-
2
1
  module Devise
3
2
  module Controllers
4
3
  module ScopedViews
@@ -15,4 +14,4 @@ module Devise
15
14
  end
16
15
  end
17
16
  end
18
- end
17
+ end