devise 3.4.0 → 3.4.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -1
- data/Gemfile.lock +1 -1
- data/README.md +6 -6
- data/app/controllers/devise_controller.rb +10 -3
- data/app/views/devise/confirmations/new.html.erb +7 -3
- data/app/views/devise/passwords/edit.html.erb +11 -5
- data/app/views/devise/passwords/new.html.erb +7 -3
- data/app/views/devise/registrations/edit.html.erb +19 -9
- data/app/views/devise/registrations/new.html.erb +18 -7
- data/app/views/devise/sessions/new.html.erb +15 -6
- data/app/views/devise/unlocks/new.html.erb +7 -3
- data/devise.gemspec +1 -0
- data/gemfiles/Gemfile.rails-3.2-stable.lock +1 -1
- data/gemfiles/Gemfile.rails-4.0-stable.lock +1 -1
- data/gemfiles/Gemfile.rails-4.1-stable.lock +1 -1
- data/lib/devise/failure_app.rb +3 -1
- data/lib/devise/version.rb +1 -1
- data/lib/generators/devise/controllers_generator.rb +1 -1
- data/test/controllers/internal_helpers_test.rb +6 -0
- data/test/failure_app_test.rb +7 -0
- data/test/models/confirmable_test.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d870f50c7470c763a16239c45bfb289c6a2b4515
|
4
|
+
data.tar.gz: 0d38550a1563a511dd37b3fd7f7ce0cac3886108
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d506c1450e20586c49e8ce2202821c2ed78d266876cb7c075795ea5efacaf748361cfdfc524dc2c87e7e093d2a85a9d8dd86faf12fa1c3b2fba1f691b0ceac29
|
7
|
+
data.tar.gz: a486ab066399291c8d4bdfb73c789c44f11d26722d2a9f3f6fd7ffc9e5933a6e3f6383c39ff62a68cbf025c0e0c087a5732a5801377e4758e1a83656d0476479
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,14 @@
|
|
1
1
|
### Unreleased
|
2
2
|
|
3
|
+
### 3.4.1
|
4
|
+
|
3
5
|
* enhancements
|
6
|
+
* Devise default views now have a similar markup to Rails scaffold views. (by @udaysinghcode, @cllns)
|
7
|
+
* Passing `now: true` to the `set_flash_message` helper now sets the message into
|
8
|
+
the `flash.now` Hash. (by @hbriggs)
|
4
9
|
* bugfixes
|
10
|
+
* Fixed an regression with translation of flash messages for when the `authentication_keys`
|
11
|
+
config is a Hash. (by @lucasmazza)
|
5
12
|
|
6
13
|
### 3.4.0
|
7
14
|
|
@@ -10,7 +17,6 @@
|
|
10
17
|
the extraction of the `respond_with` API from Rails. (by @lucasmazza)
|
11
18
|
* The Simple Form templates follow the same change from 3.3.0 by using `Log in` and adding
|
12
19
|
a hint about the minimum password length when `validatable` is enabled. (by @aried3r)
|
13
|
-
* Remove reloading of routes when eager loading is enabled. This change was added during Rails 3 and it doesn't seem to be relevant to currently supported Rails versions (by @fgro)
|
14
20
|
* Controller generator added as `devise:controllers SCOPE`. You can use the `-c` flag
|
15
21
|
to pick which controllers (`unlocks`, `confirmations`, etc) you want to generate. (by @Chun-Yang)
|
16
22
|
* Removed the hardcoded references for "email" in the flash messages. If you are using
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -289,11 +289,11 @@ If the customization at the views level is not enough, you can customize each co
|
|
289
289
|
rails generate devise:controllers [scope]
|
290
290
|
```
|
291
291
|
|
292
|
-
If you specify `
|
292
|
+
If you specify `users` as the scope, controllers will be created in `app/controllers/users/`.
|
293
293
|
And the sessions controller will look like this:
|
294
294
|
|
295
295
|
```ruby
|
296
|
-
class
|
296
|
+
class Users::SessionsController < Devise::SessionsController
|
297
297
|
# GET /resource/sign_in
|
298
298
|
# def new
|
299
299
|
# super
|
@@ -305,17 +305,17 @@ If the customization at the views level is not enough, you can customize each co
|
|
305
305
|
2. Tell the router to use this controller:
|
306
306
|
|
307
307
|
```ruby
|
308
|
-
devise_for :
|
308
|
+
devise_for :users, controllers: { sessions: "users/sessions" }
|
309
309
|
```
|
310
310
|
|
311
|
-
3. Copy the views from `devise/sessions` to `
|
311
|
+
3. Copy the views from `devise/sessions` to `users/sessions`. Since the controller was changed, it won't use the default views located in `devise/sessions`.
|
312
312
|
|
313
313
|
4. Finally, change or extend the desired controller actions.
|
314
314
|
|
315
315
|
You can completely override a controller action:
|
316
316
|
|
317
317
|
```ruby
|
318
|
-
class
|
318
|
+
class Users::SessionsController < Devise::SessionsController
|
319
319
|
def create
|
320
320
|
# custom sign-in code
|
321
321
|
end
|
@@ -325,7 +325,7 @@ If the customization at the views level is not enough, you can customize each co
|
|
325
325
|
Or you can simply add new behaviour to it:
|
326
326
|
|
327
327
|
```ruby
|
328
|
-
class
|
328
|
+
class Users::SessionsController < Devise::SessionsController
|
329
329
|
def create
|
330
330
|
super do |resource|
|
331
331
|
BackgroundWorker.trigger(resource)
|
@@ -129,8 +129,11 @@ MESSAGE
|
|
129
129
|
end
|
130
130
|
|
131
131
|
# Sets the flash message with :key, using I18n. By default you are able
|
132
|
-
# to setup your messages using specific resource scope, and if no
|
133
|
-
# found we look to default scope.
|
132
|
+
# to setup your messages using specific resource scope, and if no message is
|
133
|
+
# found we look to the default scope. Set the "now" options key to a true
|
134
|
+
# value to populate the flash.now hash in lieu of the default flash hash (so
|
135
|
+
# the flash message will be available to the current action instead of the
|
136
|
+
# next action).
|
134
137
|
# Example (i18n locale file):
|
135
138
|
#
|
136
139
|
# en:
|
@@ -144,7 +147,11 @@ MESSAGE
|
|
144
147
|
# available.
|
145
148
|
def set_flash_message(key, kind, options = {})
|
146
149
|
message = find_message(kind, options)
|
147
|
-
|
150
|
+
if options[:now]
|
151
|
+
flash.now[key] = message if message.present?
|
152
|
+
else
|
153
|
+
flash[key] = message if message.present?
|
154
|
+
end
|
148
155
|
end
|
149
156
|
|
150
157
|
def devise_i18n_options(options)
|
@@ -3,10 +3,14 @@
|
|
3
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
|
-
<div
|
7
|
-
|
6
|
+
<div class="field">
|
7
|
+
<%= f.label :email %><br />
|
8
|
+
<%= f.email_field :email, autofocus: true %>
|
9
|
+
</div>
|
8
10
|
|
9
|
-
<div
|
11
|
+
<div class="actions">
|
12
|
+
<%= f.submit "Resend confirmation instructions" %>
|
13
|
+
</div>
|
10
14
|
<% end %>
|
11
15
|
|
12
16
|
<%= render "devise/shared/links" %>
|
@@ -4,13 +4,19 @@
|
|
4
4
|
<%= devise_error_messages! %>
|
5
5
|
<%= f.hidden_field :reset_password_token %>
|
6
6
|
|
7
|
-
<div
|
8
|
-
<%= f.
|
7
|
+
<div class="field">
|
8
|
+
<%= f.label :password, "New password" %><br />
|
9
|
+
<%= f.password_field :password, autofocus: true, autocomplete: "off" %>
|
10
|
+
</div>
|
9
11
|
|
10
|
-
<div
|
11
|
-
<%= f.
|
12
|
+
<div class="field">
|
13
|
+
<%= f.label :password_confirmation, "Confirm new password" %><br />
|
14
|
+
<%= f.password_field :password_confirmation, autocomplete: "off" %>
|
15
|
+
</div>
|
12
16
|
|
13
|
-
<div
|
17
|
+
<div class="actions">
|
18
|
+
<%= f.submit "Change my password" %>
|
19
|
+
</div>
|
14
20
|
<% end %>
|
15
21
|
|
16
22
|
<%= render "devise/shared/links" %>
|
@@ -3,10 +3,14 @@
|
|
3
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
|
-
<div
|
7
|
-
|
6
|
+
<div class="field">
|
7
|
+
<%= f.label :email %><br />
|
8
|
+
<%= f.email_field :email, autofocus: true %>
|
9
|
+
</div>
|
8
10
|
|
9
|
-
<div
|
11
|
+
<div class="actions">
|
12
|
+
<%= f.submit "Send me reset password instructions" %>
|
13
|
+
</div>
|
10
14
|
<% end %>
|
11
15
|
|
12
16
|
<%= render "devise/shared/links" %>
|
@@ -3,23 +3,33 @@
|
|
3
3
|
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
|
4
4
|
<%= devise_error_messages! %>
|
5
5
|
|
6
|
-
<div
|
7
|
-
|
6
|
+
<div class="field">
|
7
|
+
<%= f.label :email %><br />
|
8
|
+
<%= f.email_field :email, autofocus: true %>
|
9
|
+
</div>
|
8
10
|
|
9
11
|
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
|
10
12
|
<div>Currently waiting confirmation for: <%= resource.unconfirmed_email %></div>
|
11
13
|
<% end %>
|
12
14
|
|
13
|
-
<div
|
14
|
-
<%= f.
|
15
|
+
<div class="field">
|
16
|
+
<%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
|
17
|
+
<%= f.password_field :password, autocomplete: "off" %>
|
18
|
+
</div>
|
15
19
|
|
16
|
-
<div
|
17
|
-
<%= f.
|
20
|
+
<div class="field">
|
21
|
+
<%= f.label :password_confirmation %><br />
|
22
|
+
<%= f.password_field :password_confirmation, autocomplete: "off" %>
|
23
|
+
</div>
|
18
24
|
|
19
|
-
<div
|
20
|
-
<%= f.
|
25
|
+
<div class="field">
|
26
|
+
<%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
|
27
|
+
<%= f.password_field :current_password, autocomplete: "off" %>
|
28
|
+
</div>
|
21
29
|
|
22
|
-
<div
|
30
|
+
<div class="actions">
|
31
|
+
<%= f.submit "Update" %>
|
32
|
+
</div>
|
23
33
|
<% end %>
|
24
34
|
|
25
35
|
<h3>Cancel my account</h3>
|
@@ -3,16 +3,27 @@
|
|
3
3
|
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
|
4
4
|
<%= devise_error_messages! %>
|
5
5
|
|
6
|
-
<div
|
7
|
-
|
6
|
+
<div class="field">
|
7
|
+
<%= f.label :email %><br />
|
8
|
+
<%= f.email_field :email, autofocus: true %>
|
9
|
+
</div>
|
8
10
|
|
9
|
-
<div
|
10
|
-
<%= f.
|
11
|
+
<div class="field">
|
12
|
+
<%= f.label :password %>
|
13
|
+
<% if @validatable %>
|
14
|
+
<em>(<%= @minimum_password_length %> characters minimum)</em>
|
15
|
+
<% end %><br />
|
16
|
+
<%= f.password_field :password, autocomplete: "off" %>
|
17
|
+
</div>
|
11
18
|
|
12
|
-
<div
|
13
|
-
<%= f.
|
19
|
+
<div class="field">
|
20
|
+
<%= f.label :password_confirmation %><br />
|
21
|
+
<%= f.password_field :password_confirmation, autocomplete: "off" %>
|
22
|
+
</div>
|
14
23
|
|
15
|
-
<div
|
24
|
+
<div class="actions">
|
25
|
+
<%= f.submit "Sign up" %>
|
26
|
+
</div>
|
16
27
|
<% end %>
|
17
28
|
|
18
29
|
<%= render "devise/shared/links" %>
|
@@ -1,17 +1,26 @@
|
|
1
1
|
<h2>Log in</h2>
|
2
2
|
|
3
3
|
<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
|
4
|
-
<div
|
5
|
-
|
4
|
+
<div class="field">
|
5
|
+
<%= f.label :email %><br />
|
6
|
+
<%= f.email_field :email, autofocus: true %>
|
7
|
+
</div>
|
6
8
|
|
7
|
-
<div
|
8
|
-
<%= f.
|
9
|
+
<div class="field">
|
10
|
+
<%= f.label :password %><br />
|
11
|
+
<%= f.password_field :password, autocomplete: "off" %>
|
12
|
+
</div>
|
9
13
|
|
10
14
|
<% if devise_mapping.rememberable? -%>
|
11
|
-
<div
|
15
|
+
<div class="field">
|
16
|
+
<%= f.check_box :remember_me %>
|
17
|
+
<%= f.label :remember_me %>
|
18
|
+
</div>
|
12
19
|
<% end -%>
|
13
20
|
|
14
|
-
<div
|
21
|
+
<div class="actions">
|
22
|
+
<%= f.submit "Log in" %>
|
23
|
+
</div>
|
15
24
|
<% end %>
|
16
25
|
|
17
26
|
<%= render "devise/shared/links" %>
|
@@ -3,10 +3,14 @@
|
|
3
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
|
-
<div
|
7
|
-
|
6
|
+
<div class="field">
|
7
|
+
<%= f.label :email %><br />
|
8
|
+
<%= f.email_field :email, autofocus: true %>
|
9
|
+
</div>
|
8
10
|
|
9
|
-
<div
|
11
|
+
<div class="actions">
|
12
|
+
<%= f.submit "Resend unlock instructions" %>
|
13
|
+
</div>
|
10
14
|
<% end %>
|
11
15
|
|
12
16
|
<%= render "devise/shared/links" %>
|
data/devise.gemspec
CHANGED
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.files = `git ls-files`.split("\n")
|
19
19
|
s.test_files = `git ls-files -- test/*`.split("\n")
|
20
20
|
s.require_paths = ["lib"]
|
21
|
+
s.required_ruby_version = '>= 1.9.3'
|
21
22
|
|
22
23
|
s.add_dependency("warden", "~> 1.2.3")
|
23
24
|
s.add_dependency("orm_adapter", "~> 0.1")
|
data/lib/devise/failure_app.rb
CHANGED
@@ -78,7 +78,9 @@ module Devise
|
|
78
78
|
options[:resource_name] = scope
|
79
79
|
options[:scope] = "devise.failure"
|
80
80
|
options[:default] = [message]
|
81
|
-
|
81
|
+
auth_keys = scope_class.authentication_keys
|
82
|
+
keys = auth_keys.respond_to?(:keys) ? auth_keys.keys : auth_keys
|
83
|
+
options[:authentication_keys] = keys.join(I18n.translate(:"support.array.words_connector"))
|
82
84
|
options = i18n_options(options)
|
83
85
|
|
84
86
|
I18n.t(:"#{scope}.#{message}", options)
|
data/lib/devise/version.rb
CHANGED
@@ -8,7 +8,7 @@ module Devise
|
|
8
8
|
desc <<-DESC.strip_heredoc
|
9
9
|
Create inherited Devise controllers in your app/controllers folder.
|
10
10
|
|
11
|
-
|
11
|
+
Use -c to specify which controller you want to overwrite.
|
12
12
|
If you do no specify a controller, all controllers will be created.
|
13
13
|
For example:
|
14
14
|
|
@@ -99,6 +99,12 @@ class HelpersTest < ActionController::TestCase
|
|
99
99
|
assert_equal 'non-blank', flash[:notice]
|
100
100
|
end
|
101
101
|
|
102
|
+
test 'issues non-blank flash.now messages normally' do
|
103
|
+
I18n.stubs(:t).returns('non-blank')
|
104
|
+
@controller.send :set_flash_message, :notice, :send_instructions, { now: true }
|
105
|
+
assert_equal 'non-blank', flash.now[:notice]
|
106
|
+
end
|
107
|
+
|
102
108
|
test 'uses custom i18n options' do
|
103
109
|
@controller.stubs(:devise_i18n_options).returns(default: "devise custom options")
|
104
110
|
@controller.send :set_flash_message, :notice, :invalid_i18n_messagesend_instructions
|
data/test/failure_app_test.rb
CHANGED
@@ -109,6 +109,13 @@ class FailureTest < ActiveSupport::TestCase
|
|
109
109
|
assert_equal 'http://test.host/users/sign_in', @response.second["Location"]
|
110
110
|
end
|
111
111
|
|
112
|
+
test 'supports authentication_keys as a Hash for the flash message' do
|
113
|
+
swap Devise, authentication_keys: { email: true, login: true } do
|
114
|
+
call_failure('warden' => OpenStruct.new(message: :invalid))
|
115
|
+
assert_equal 'Invalid email, login or password.', @request.flash[:alert]
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
112
119
|
test 'uses custom i18n options' do
|
113
120
|
call_failure('warden' => OpenStruct.new(message: :does_not_exist), app: FailureWithI18nOptions)
|
114
121
|
assert_equal 'User Steve does not exist', @request.flash[:alert]
|
@@ -219,14 +219,14 @@ class ConfirmableTest < ActiveSupport::TestCase
|
|
219
219
|
test 'should not be active when confirm in is zero' do
|
220
220
|
Devise.allow_unconfirmed_access_for = 0.days
|
221
221
|
user = create_user
|
222
|
-
user.confirmation_sent_at =
|
222
|
+
user.confirmation_sent_at = Time.zone.today
|
223
223
|
assert_not user.active_for_authentication?
|
224
224
|
end
|
225
225
|
|
226
226
|
test 'should be active when we set allow_unconfirmed_access_for to nil' do
|
227
227
|
swap Devise, allow_unconfirmed_access_for: nil do
|
228
228
|
user = create_user
|
229
|
-
user.confirmation_sent_at =
|
229
|
+
user.confirmation_sent_at = Time.zone.today
|
230
230
|
assert user.active_for_authentication?
|
231
231
|
end
|
232
232
|
end
|
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: 3.4.
|
4
|
+
version: 3.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- José Valim
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-10-
|
12
|
+
date: 2014-10-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: warden
|
@@ -362,7 +362,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
362
362
|
requirements:
|
363
363
|
- - ">="
|
364
364
|
- !ruby/object:Gem::Version
|
365
|
-
version:
|
365
|
+
version: 1.9.3
|
366
366
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
367
367
|
requirements:
|
368
368
|
- - ">="
|