devise 3.4.1 → 3.5.1

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.

Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +26 -16
  3. data/CHANGELOG.md +131 -104
  4. data/Gemfile +1 -1
  5. data/Gemfile.lock +84 -85
  6. data/MIT-LICENSE +1 -1
  7. data/README.md +52 -32
  8. data/Rakefile +2 -1
  9. data/app/controllers/devise/confirmations_controller.rb +4 -0
  10. data/app/controllers/devise/omniauth_callbacks_controller.rb +4 -0
  11. data/app/controllers/devise/passwords_controller.rb +14 -4
  12. data/app/controllers/devise/registrations_controller.rb +10 -11
  13. data/app/controllers/devise/sessions_controller.rb +7 -2
  14. data/app/controllers/devise/unlocks_controller.rb +3 -0
  15. data/app/controllers/devise_controller.rb +34 -18
  16. data/app/views/devise/confirmations/new.html.erb +1 -1
  17. data/app/views/devise/passwords/edit.html.erb +3 -0
  18. data/app/views/devise/registrations/new.html.erb +1 -1
  19. data/gemfiles/Gemfile.rails-3.2-stable.lock +43 -43
  20. data/gemfiles/Gemfile.rails-4.0-stable.lock +45 -47
  21. data/gemfiles/Gemfile.rails-4.1-stable.lock +52 -53
  22. data/gemfiles/Gemfile.rails-4.2-stable +29 -0
  23. data/gemfiles/Gemfile.rails-4.2-stable.lock +191 -0
  24. data/lib/devise.rb +23 -28
  25. data/lib/devise/controllers/rememberable.rb +1 -1
  26. data/lib/devise/controllers/sign_in_out.rb +1 -1
  27. data/lib/devise/controllers/store_location.rb +3 -1
  28. data/lib/devise/controllers/url_helpers.rb +7 -9
  29. data/lib/devise/encryptor.rb +22 -0
  30. data/lib/devise/failure_app.rb +26 -10
  31. data/lib/devise/mapping.rb +1 -0
  32. data/lib/devise/models/authenticatable.rb +20 -26
  33. data/lib/devise/models/confirmable.rb +29 -7
  34. data/lib/devise/models/database_authenticatable.rb +6 -9
  35. data/lib/devise/models/recoverable.rb +22 -10
  36. data/lib/devise/models/rememberable.rb +16 -3
  37. data/lib/devise/models/trackable.rb +1 -2
  38. data/lib/devise/models/validatable.rb +3 -3
  39. data/lib/devise/rails.rb +1 -1
  40. data/lib/devise/rails/routes.rb +3 -3
  41. data/lib/devise/strategies/authenticatable.rb +5 -2
  42. data/lib/devise/strategies/database_authenticatable.rb +1 -1
  43. data/lib/devise/strategies/rememberable.rb +10 -0
  44. data/lib/devise/test_helpers.rb +2 -2
  45. data/lib/devise/version.rb +1 -1
  46. data/lib/generators/active_record/templates/migration.rb +1 -1
  47. data/lib/generators/active_record/templates/migration_existing.rb +1 -1
  48. data/lib/generators/templates/controllers/README +1 -1
  49. data/lib/generators/templates/controllers/omniauth_callbacks_controller.rb +1 -1
  50. data/lib/generators/templates/controllers/registrations_controller.rb +2 -2
  51. data/lib/generators/templates/controllers/sessions_controller.rb +1 -1
  52. data/lib/generators/templates/devise.rb +14 -8
  53. data/lib/generators/templates/simple_form_for/passwords/edit.html.erb +1 -1
  54. data/lib/generators/templates/simple_form_for/registrations/new.html.erb +1 -1
  55. data/test/controllers/custom_registrations_controller_test.rb +6 -1
  56. data/test/controllers/helpers_test.rb +5 -0
  57. data/test/controllers/inherited_controller_i18n_messages_test.rb +51 -0
  58. data/test/controllers/internal_helpers_test.rb +4 -4
  59. data/test/controllers/load_hooks_controller_test.rb +19 -0
  60. data/test/controllers/passwords_controller_test.rb +1 -1
  61. data/test/controllers/sessions_controller_test.rb +3 -3
  62. data/test/devise_test.rb +2 -2
  63. data/test/failure_app_test.rb +23 -0
  64. data/test/integration/database_authenticatable_test.rb +11 -0
  65. data/test/integration/omniauthable_test.rb +1 -1
  66. data/test/integration/recoverable_test.rb +13 -0
  67. data/test/integration/rememberable_test.rb +9 -0
  68. data/test/mapping_test.rb +6 -0
  69. data/test/models/confirmable_test.rb +47 -34
  70. data/test/models/lockable_test.rb +6 -6
  71. data/test/models/recoverable_test.rb +39 -7
  72. data/test/models/rememberable_test.rb +8 -2
  73. data/test/models/validatable_test.rb +5 -5
  74. data/test/rails_app/app/controllers/custom/registrations_controller.rb +10 -0
  75. data/test/rails_app/config/application.rb +1 -1
  76. data/test/rails_app/config/environments/production.rb +6 -2
  77. data/test/rails_app/config/environments/test.rb +7 -2
  78. data/test/rails_app/config/initializers/devise.rb +12 -15
  79. data/test/rails_app/lib/shared_user.rb +1 -1
  80. data/test/rails_test.rb +9 -0
  81. data/test/support/integration.rb +2 -2
  82. data/test/test_helpers_test.rb +22 -7
  83. data/test/test_models.rb +2 -2
  84. metadata +11 -2
@@ -1,47 +1,47 @@
1
1
  GIT
2
2
  remote: git://github.com/rails/rails.git
3
- revision: 90b70cd453e6b88b2ad484861ad9913f70bd15c9
3
+ revision: bf32ec7b8611e6b4c7e9398f7d297a1f0221e9b9
4
4
  branch: 4-1-stable
5
5
  specs:
6
- actionmailer (4.1.5)
7
- actionpack (= 4.1.5)
8
- actionview (= 4.1.5)
6
+ actionmailer (4.1.10)
7
+ actionpack (= 4.1.10)
8
+ actionview (= 4.1.10)
9
9
  mail (~> 2.5, >= 2.5.4)
10
- actionpack (4.1.5)
11
- actionview (= 4.1.5)
12
- activesupport (= 4.1.5)
10
+ actionpack (4.1.10)
11
+ actionview (= 4.1.10)
12
+ activesupport (= 4.1.10)
13
13
  rack (~> 1.5.2)
14
14
  rack-test (~> 0.6.2)
15
- actionview (4.1.5)
16
- activesupport (= 4.1.5)
15
+ actionview (4.1.10)
16
+ activesupport (= 4.1.10)
17
17
  builder (~> 3.1)
18
18
  erubis (~> 2.7.0)
19
- activemodel (4.1.5)
20
- activesupport (= 4.1.5)
19
+ activemodel (4.1.10)
20
+ activesupport (= 4.1.10)
21
21
  builder (~> 3.1)
22
- activerecord (4.1.5)
23
- activemodel (= 4.1.5)
24
- activesupport (= 4.1.5)
22
+ activerecord (4.1.10)
23
+ activemodel (= 4.1.10)
24
+ activesupport (= 4.1.10)
25
25
  arel (~> 5.0.0)
26
- activesupport (4.1.5)
26
+ activesupport (4.1.10)
27
27
  i18n (~> 0.6, >= 0.6.9)
28
28
  json (~> 1.7, >= 1.7.7)
29
29
  minitest (~> 5.1)
30
30
  thread_safe (~> 0.1)
31
31
  tzinfo (~> 1.1)
32
- rails (4.1.5)
33
- actionmailer (= 4.1.5)
34
- actionpack (= 4.1.5)
35
- actionview (= 4.1.5)
36
- activemodel (= 4.1.5)
37
- activerecord (= 4.1.5)
38
- activesupport (= 4.1.5)
32
+ rails (4.1.10)
33
+ actionmailer (= 4.1.10)
34
+ actionpack (= 4.1.10)
35
+ actionview (= 4.1.10)
36
+ activemodel (= 4.1.10)
37
+ activerecord (= 4.1.10)
38
+ activesupport (= 4.1.10)
39
39
  bundler (>= 1.3.0, < 2.0)
40
- railties (= 4.1.5)
40
+ railties (= 4.1.10)
41
41
  sprockets-rails (~> 2.0)
42
- railties (4.1.5)
43
- actionpack (= 4.1.5)
44
- activesupport (= 4.1.5)
42
+ railties (4.1.10)
43
+ actionpack (= 4.1.10)
44
+ activesupport (= 4.1.10)
45
45
  rake (>= 0.8.7)
46
46
  thor (>= 0.18.1, < 2.0)
47
47
 
@@ -60,40 +60,40 @@ GEM
60
60
  remote: https://rubygems.org/
61
61
  specs:
62
62
  arel (5.0.1.20140414130214)
63
- bcrypt (3.1.7)
63
+ bcrypt (3.1.10)
64
64
  bson (2.3.0)
65
65
  builder (3.2.2)
66
- connection_pool (2.0.0)
66
+ connection_pool (2.1.3)
67
67
  erubis (2.7.0)
68
- faraday (0.9.0)
68
+ faraday (0.9.1)
69
69
  multipart-post (>= 1.2, < 3)
70
- hashie (3.2.0)
70
+ hashie (3.4.0)
71
71
  hike (1.2.3)
72
- i18n (0.6.11)
73
- json (1.8.1)
74
- jwt (1.0.0)
75
- mail (2.6.1)
72
+ i18n (0.7.0)
73
+ json (1.8.2)
74
+ jwt (1.4.1)
75
+ mail (2.6.3)
76
76
  mime-types (>= 1.16, < 3)
77
77
  metaclass (0.0.4)
78
- mime-types (2.3)
79
- mini_portile (0.6.0)
80
- minitest (5.4.0)
78
+ mime-types (2.4.3)
79
+ mini_portile (0.6.2)
80
+ minitest (5.5.1)
81
81
  mocha (1.1.0)
82
82
  metaclass (~> 0.0.1)
83
- mongoid (4.0.0)
83
+ mongoid (4.0.2)
84
84
  activemodel (~> 4.0)
85
85
  moped (~> 2.0.0)
86
86
  origin (~> 2.1)
87
87
  tzinfo (>= 0.3.37)
88
- moped (2.0.0)
88
+ moped (2.0.4)
89
89
  bson (~> 2.2)
90
90
  connection_pool (~> 2.0)
91
91
  optionable (~> 0.2.0)
92
- multi_json (1.10.1)
92
+ multi_json (1.11.0)
93
93
  multi_xml (0.5.5)
94
94
  multipart-post (2.0.0)
95
- nokogiri (1.6.3.1)
96
- mini_portile (= 0.6.0)
95
+ nokogiri (1.6.6.2)
96
+ mini_portile (~> 0.6.0)
97
97
  oauth2 (0.9.4)
98
98
  faraday (>= 0.8, < 0.10)
99
99
  jwt (~> 1.0)
@@ -120,26 +120,25 @@ GEM
120
120
  rack-openid (1.3.1)
121
121
  rack (>= 1.1.0)
122
122
  ruby-openid (>= 2.1.8)
123
- rack-test (0.6.2)
123
+ rack-test (0.6.3)
124
124
  rack (>= 1.0)
125
- rake (10.3.2)
126
- rdoc (4.1.1)
127
- json (~> 1.4)
128
- responders (1.1.1)
125
+ rake (10.4.2)
126
+ rdoc (4.2.0)
127
+ responders (1.1.2)
129
128
  railties (>= 3.2, < 4.2)
130
- ruby-openid (2.5.0)
131
- sprockets (2.12.1)
129
+ ruby-openid (2.7.0)
130
+ sprockets (2.12.3)
132
131
  hike (~> 1.2)
133
132
  multi_json (~> 1.0)
134
133
  rack (~> 1.0)
135
134
  tilt (~> 1.1, != 1.3.0)
136
- sprockets-rails (2.1.3)
135
+ sprockets-rails (2.2.4)
137
136
  actionpack (>= 3.0)
138
137
  activesupport (>= 3.0)
139
- sprockets (~> 2.8)
140
- sqlite3 (1.3.9)
138
+ sprockets (>= 2.8, < 4.0)
139
+ sqlite3 (1.3.10)
141
140
  thor (0.19.1)
142
- thread_safe (0.3.4)
141
+ thread_safe (0.3.5)
143
142
  tilt (1.4.1)
144
143
  tzinfo (1.2.2)
145
144
  thread_safe (~> 0.1)
@@ -0,0 +1,29 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec path: '..'
4
+
5
+ gem "rails", github: 'rails/rails', branch: '4-2-stable'
6
+ gem "omniauth", "~> 1.2.2"
7
+ gem "omniauth-oauth2", "~> 1.2.0"
8
+ gem "rdoc"
9
+
10
+ group :test do
11
+ gem "omniauth-facebook"
12
+ gem "omniauth-openid", "~> 1.0.1"
13
+ gem "webrat", "0.7.3", require: false
14
+ gem "mocha", "~> 1.1", require: false
15
+ end
16
+
17
+ platforms :jruby do
18
+ gem "activerecord-jdbc-adapter"
19
+ gem "activerecord-jdbcsqlite3-adapter"
20
+ gem "jruby-openssl"
21
+ end
22
+
23
+ platforms :ruby do
24
+ gem "sqlite3"
25
+ end
26
+
27
+ group :mongoid do
28
+ gem "mongoid", "~> 4.0.0"
29
+ end
@@ -0,0 +1,191 @@
1
+ GIT
2
+ remote: git://github.com/rails/rails.git
3
+ revision: f12ff8ddab7b199707ec36d72bd72f206f142c8b
4
+ branch: 4-2-stable
5
+ specs:
6
+ actionmailer (4.2.1)
7
+ actionpack (= 4.2.1)
8
+ actionview (= 4.2.1)
9
+ activejob (= 4.2.1)
10
+ mail (~> 2.5, >= 2.5.4)
11
+ rails-dom-testing (~> 1.0, >= 1.0.5)
12
+ actionpack (4.2.1)
13
+ actionview (= 4.2.1)
14
+ activesupport (= 4.2.1)
15
+ rack (~> 1.6)
16
+ rack-test (~> 0.6.2)
17
+ rails-dom-testing (~> 1.0, >= 1.0.5)
18
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
19
+ actionview (4.2.1)
20
+ activesupport (= 4.2.1)
21
+ builder (~> 3.1)
22
+ erubis (~> 2.7.0)
23
+ rails-dom-testing (~> 1.0, >= 1.0.5)
24
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
25
+ activejob (4.2.1)
26
+ activesupport (= 4.2.1)
27
+ globalid (>= 0.3.0)
28
+ activemodel (4.2.1)
29
+ activesupport (= 4.2.1)
30
+ builder (~> 3.1)
31
+ activerecord (4.2.1)
32
+ activemodel (= 4.2.1)
33
+ activesupport (= 4.2.1)
34
+ arel (~> 6.0)
35
+ activesupport (4.2.1)
36
+ i18n (~> 0.7)
37
+ json (~> 1.7, >= 1.7.7)
38
+ minitest (~> 5.1)
39
+ thread_safe (~> 0.3, >= 0.3.4)
40
+ tzinfo (~> 1.1)
41
+ rails (4.2.1)
42
+ actionmailer (= 4.2.1)
43
+ actionpack (= 4.2.1)
44
+ actionview (= 4.2.1)
45
+ activejob (= 4.2.1)
46
+ activemodel (= 4.2.1)
47
+ activerecord (= 4.2.1)
48
+ activesupport (= 4.2.1)
49
+ bundler (>= 1.3.0, < 2.0)
50
+ railties (= 4.2.1)
51
+ sprockets-rails
52
+ railties (4.2.1)
53
+ actionpack (= 4.2.1)
54
+ activesupport (= 4.2.1)
55
+ rake (>= 0.8.7)
56
+ thor (>= 0.18.1, < 2.0)
57
+
58
+ PATH
59
+ remote: ..
60
+ specs:
61
+ devise (3.4.1)
62
+ bcrypt (~> 3.0)
63
+ orm_adapter (~> 0.1)
64
+ railties (>= 3.2.6, < 5)
65
+ responders
66
+ thread_safe (~> 0.1)
67
+ warden (~> 1.2.3)
68
+
69
+ GEM
70
+ remote: https://rubygems.org/
71
+ specs:
72
+ arel (6.0.0)
73
+ bcrypt (3.1.10)
74
+ bson (2.3.0)
75
+ builder (3.2.2)
76
+ connection_pool (2.1.3)
77
+ erubis (2.7.0)
78
+ faraday (0.9.1)
79
+ multipart-post (>= 1.2, < 3)
80
+ globalid (0.3.3)
81
+ activesupport (>= 4.1.0)
82
+ hashie (3.4.0)
83
+ hike (1.2.3)
84
+ i18n (0.7.0)
85
+ json (1.8.2)
86
+ jwt (1.4.1)
87
+ loofah (2.0.1)
88
+ nokogiri (>= 1.5.9)
89
+ mail (2.6.3)
90
+ mime-types (>= 1.16, < 3)
91
+ metaclass (0.0.4)
92
+ mime-types (2.4.3)
93
+ mini_portile (0.6.2)
94
+ minitest (5.5.1)
95
+ mocha (1.1.0)
96
+ metaclass (~> 0.0.1)
97
+ mongoid (4.0.2)
98
+ activemodel (~> 4.0)
99
+ moped (~> 2.0.0)
100
+ origin (~> 2.1)
101
+ tzinfo (>= 0.3.37)
102
+ moped (2.0.4)
103
+ bson (~> 2.2)
104
+ connection_pool (~> 2.0)
105
+ optionable (~> 0.2.0)
106
+ multi_json (1.11.0)
107
+ multi_xml (0.5.5)
108
+ multipart-post (2.0.0)
109
+ nokogiri (1.6.6.2)
110
+ mini_portile (~> 0.6.0)
111
+ oauth2 (1.0.0)
112
+ faraday (>= 0.8, < 0.10)
113
+ jwt (~> 1.0)
114
+ multi_json (~> 1.3)
115
+ multi_xml (~> 0.5)
116
+ rack (~> 1.2)
117
+ omniauth (1.2.2)
118
+ hashie (>= 1.2, < 4)
119
+ rack (~> 1.0)
120
+ omniauth-facebook (2.0.1)
121
+ omniauth-oauth2 (~> 1.2)
122
+ omniauth-oauth2 (1.2.0)
123
+ faraday (>= 0.8, < 0.10)
124
+ multi_json (~> 1.3)
125
+ oauth2 (~> 1.0)
126
+ omniauth (~> 1.2)
127
+ omniauth-openid (1.0.1)
128
+ omniauth (~> 1.0)
129
+ rack-openid (~> 1.3.1)
130
+ optionable (0.2.0)
131
+ origin (2.1.1)
132
+ orm_adapter (0.5.0)
133
+ rack (1.6.0)
134
+ rack-openid (1.3.1)
135
+ rack (>= 1.1.0)
136
+ ruby-openid (>= 2.1.8)
137
+ rack-test (0.6.3)
138
+ rack (>= 1.0)
139
+ rails-deprecated_sanitizer (1.0.3)
140
+ activesupport (>= 4.2.0.alpha)
141
+ rails-dom-testing (1.0.6)
142
+ activesupport (>= 4.2.0.beta, < 5.0)
143
+ nokogiri (~> 1.6.0)
144
+ rails-deprecated_sanitizer (>= 1.0.1)
145
+ rails-html-sanitizer (1.0.2)
146
+ loofah (~> 2.0)
147
+ rake (10.4.2)
148
+ rdoc (4.2.0)
149
+ responders (2.1.0)
150
+ railties (>= 4.2.0, < 5)
151
+ ruby-openid (2.7.0)
152
+ sprockets (2.12.3)
153
+ hike (~> 1.2)
154
+ multi_json (~> 1.0)
155
+ rack (~> 1.0)
156
+ tilt (~> 1.1, != 1.3.0)
157
+ sprockets-rails (2.2.4)
158
+ actionpack (>= 3.0)
159
+ activesupport (>= 3.0)
160
+ sprockets (>= 2.8, < 4.0)
161
+ sqlite3 (1.3.10)
162
+ thor (0.19.1)
163
+ thread_safe (0.3.5)
164
+ tilt (1.4.1)
165
+ tzinfo (1.2.2)
166
+ thread_safe (~> 0.1)
167
+ warden (1.2.3)
168
+ rack (>= 1.0)
169
+ webrat (0.7.3)
170
+ nokogiri (>= 1.2.0)
171
+ rack (>= 1.0)
172
+ rack-test (>= 0.5.3)
173
+
174
+ PLATFORMS
175
+ ruby
176
+
177
+ DEPENDENCIES
178
+ activerecord-jdbc-adapter
179
+ activerecord-jdbcsqlite3-adapter
180
+ devise!
181
+ jruby-openssl
182
+ mocha (~> 1.1)
183
+ mongoid (~> 4.0.0)
184
+ omniauth (~> 1.2.2)
185
+ omniauth-facebook
186
+ omniauth-oauth2 (~> 1.2.0)
187
+ omniauth-openid (~> 1.0.1)
188
+ rails!
189
+ rdoc
190
+ sqlite3
191
+ webrat (= 0.7.3)
@@ -57,22 +57,6 @@ module Devise
57
57
  mattr_accessor :secret_key
58
58
  @@secret_key = nil
59
59
 
60
- [ :allow_insecure_token_lookup,
61
- :allow_insecure_sign_in_after_confirmation,
62
- :token_authentication_key ].each do |method|
63
- class_eval <<-RUBY
64
- def self.#{method}
65
- ActiveSupport::Deprecation.warn "Devise.#{method} is deprecated " \
66
- "and has no effect"
67
- end
68
-
69
- def self.#{method}=(val)
70
- ActiveSupport::Deprecation.warn "Devise.#{method}= is deprecated " \
71
- "and has no effect"
72
- end
73
- RUBY
74
- end
75
-
76
60
  # Custom domain or key for cookies. Not set by default
77
61
  mattr_accessor :rememberable_options
78
62
  @@rememberable_options = {}
@@ -87,7 +71,7 @@ module Devise
87
71
 
88
72
  # Keys used when authenticating a user.
89
73
  mattr_accessor :authentication_keys
90
- @@authentication_keys = [ :email ]
74
+ @@authentication_keys = [:email]
91
75
 
92
76
  # Request keys used when authenticating a user.
93
77
  mattr_accessor :request_keys
@@ -95,7 +79,7 @@ module Devise
95
79
 
96
80
  # Keys that should be case-insensitive.
97
81
  mattr_accessor :case_insensitive_keys
98
- @@case_insensitive_keys = [ :email ]
82
+ @@case_insensitive_keys = [:email]
99
83
 
100
84
  # Keys that should have whitespace stripped.
101
85
  mattr_accessor :strip_whitespace_keys
@@ -150,7 +134,7 @@ module Devise
150
134
 
151
135
  # Defines which key will be used when confirming an account.
152
136
  mattr_accessor :confirmation_keys
153
- @@confirmation_keys = [ :email ]
137
+ @@confirmation_keys = [:email]
154
138
 
155
139
  # Defines if email should be reconfirmable.
156
140
  # False by default for backwards compatibility.
@@ -181,7 +165,7 @@ module Devise
181
165
 
182
166
  # Defines which key will be used when locking and unlocking an account
183
167
  mattr_accessor :unlock_keys
184
- @@unlock_keys = [ :email ]
168
+ @@unlock_keys = [:email]
185
169
 
186
170
  # Defines which strategy can be used to unlock an account.
187
171
  # Values: :email, :time, :both
@@ -198,12 +182,16 @@ module Devise
198
182
 
199
183
  # Defines which key will be used when recovering the password for an account
200
184
  mattr_accessor :reset_password_keys
201
- @@reset_password_keys = [ :email ]
185
+ @@reset_password_keys = [:email]
202
186
 
203
187
  # Time interval you can reset your password with a reset password key
204
188
  mattr_accessor :reset_password_within
205
189
  @@reset_password_within = 6.hours
206
190
 
191
+ # When set to false, resetting a password does not automatically sign in a user
192
+ mattr_accessor :sign_in_after_reset_password
193
+ @@sign_in_after_reset_password = true
194
+
207
195
  # The default scope which is used by warden.
208
196
  mattr_accessor :default_scope
209
197
  @@default_scope = nil
@@ -246,7 +234,7 @@ module Devise
246
234
  mattr_accessor :router_name
247
235
  @@router_name = nil
248
236
 
249
- # Set the omniauth path prefix so it can be overridden when
237
+ # Set the OmniAuth path prefix so it can be overridden when
250
238
  # Devise is used in a mountable engine
251
239
  mattr_accessor :omniauth_path_prefix
252
240
  @@omniauth_path_prefix = nil
@@ -261,7 +249,7 @@ module Devise
261
249
  mattr_reader :mappings
262
250
  @@mappings = ActiveSupport::OrderedHash.new
263
251
 
264
- # Omniauth configurations.
252
+ # OmniAuth configurations.
265
253
  mattr_reader :omniauth_configs
266
254
  @@omniauth_configs = ActiveSupport::OrderedHash.new
267
255
 
@@ -348,6 +336,7 @@ module Devise
348
336
  # +controller+ - Symbol representing the name of an existing or custom *controller* for this module.
349
337
  # +route+ - Symbol representing the named *route* helper for this module.
350
338
  # +strategy+ - Symbol representing if this module got a custom *strategy*.
339
+ # +insert_at+ - Integer representing the order in which this module's model will be included
351
340
  #
352
341
  # All values, except :model, accept also a boolean and will have the same name as the given module
353
342
  # name.
@@ -357,10 +346,12 @@ module Devise
357
346
  # Devise.add_module(:party_module)
358
347
  # Devise.add_module(:party_module, strategy: true, controller: :sessions)
359
348
  # Devise.add_module(:party_module, model: 'party_module/model')
349
+ # Devise.add_module(:party_module, insert_at: 0)
360
350
  #
361
351
  def self.add_module(module_name, options = {})
362
- ALL << module_name
363
- options.assert_valid_keys(:strategy, :model, :controller, :route, :no_input)
352
+ options.assert_valid_keys(:strategy, :model, :controller, :route, :no_input, :insert_at)
353
+
354
+ ALL.insert (options[:insert_at] || -1), module_name
364
355
 
365
356
  if strategy = options[:strategy]
366
357
  strategy = (strategy == true ? module_name : strategy)
@@ -417,7 +408,7 @@ module Devise
417
408
  @@warden_config_blocks << block
418
409
  end
419
410
 
420
- # Specify an omniauth provider.
411
+ # Specify an OmniAuth provider.
421
412
  #
422
413
  # config.omniauth :github, APP_ID, APP_SECRET
423
414
  #
@@ -474,8 +465,12 @@ module Devise
474
465
  end
475
466
 
476
467
  # Generate a friendly string randomly to be used as token.
477
- def self.friendly_token
478
- SecureRandom.urlsafe_base64(15).tr('lIO0', 'sxyz')
468
+ # By default, length is 20 characters.
469
+ def self.friendly_token(length = 20)
470
+ # To calculate real characters, we must perform this operation.
471
+ # See SecureRandom.urlsafe_base64
472
+ rlength = (length * 3) / 4
473
+ SecureRandom.urlsafe_base64(rlength).tr('lIO0', 'sxyz')
479
474
  end
480
475
 
481
476
  # constant-time comparison algorithm to prevent timing attacks