devise 2.1.2 → 3.5.10
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 +7 -0
- data/.travis.yml +39 -10
- data/.yardopts +9 -0
- data/{CHANGELOG.rdoc → CHANGELOG.md} +445 -112
- data/CODE_OF_CONDUCT.md +22 -0
- data/CONTRIBUTING.md +16 -0
- data/Gemfile +10 -15
- data/Gemfile.lock +151 -129
- data/MIT-LICENSE +1 -1
- data/README.md +256 -96
- data/Rakefile +4 -2
- data/app/controllers/devise/confirmations_controller.rb +15 -7
- data/app/controllers/devise/omniauth_callbacks_controller.rb +6 -2
- data/app/controllers/devise/passwords_controller.rb +33 -9
- data/app/controllers/devise/registrations_controller.rb +66 -26
- data/app/controllers/devise/sessions_controller.rb +52 -21
- data/app/controllers/devise/unlocks_controller.rb +11 -6
- data/app/controllers/devise_controller.rb +65 -58
- data/app/helpers/devise_helper.rb +2 -2
- data/app/mailers/devise/mailer.rb +19 -10
- data/app/views/devise/confirmations/new.html.erb +8 -4
- data/app/views/devise/mailer/confirmation_instructions.html.erb +2 -2
- data/app/views/devise/mailer/password_change.html.erb +3 -0
- data/app/views/devise/mailer/reset_password_instructions.html.erb +2 -2
- data/app/views/devise/mailer/unlock_instructions.html.erb +2 -2
- data/app/views/devise/passwords/edit.html.erb +15 -6
- data/app/views/devise/passwords/new.html.erb +8 -4
- data/app/views/devise/registrations/edit.html.erb +29 -15
- data/app/views/devise/registrations/new.html.erb +19 -8
- data/app/views/devise/sessions/new.html.erb +17 -8
- data/app/views/devise/shared/{_links.erb → _links.html.erb} +4 -4
- data/app/views/devise/unlocks/new.html.erb +8 -4
- data/config/locales/en.yml +51 -47
- data/devise.gemspec +8 -6
- data/devise.png +0 -0
- data/gemfiles/Gemfile.rails-3.2-stable +29 -0
- data/gemfiles/Gemfile.rails-3.2-stable.lock +172 -0
- data/gemfiles/Gemfile.rails-4.0-stable +30 -0
- data/gemfiles/Gemfile.rails-4.0-stable.lock +166 -0
- data/gemfiles/Gemfile.rails-4.1-stable +30 -0
- data/gemfiles/Gemfile.rails-4.1-stable.lock +171 -0
- data/gemfiles/Gemfile.rails-4.2-stable +30 -0
- data/gemfiles/Gemfile.rails-4.2-stable.lock +193 -0
- data/lib/devise/controllers/helpers.rb +126 -108
- data/lib/devise/controllers/rememberable.rb +19 -17
- data/lib/devise/controllers/scoped_views.rb +1 -1
- data/lib/devise/controllers/sign_in_out.rb +96 -0
- data/lib/devise/controllers/store_location.rb +58 -0
- data/lib/devise/controllers/url_helpers.rb +7 -7
- data/lib/devise/encryptor.rb +22 -0
- data/lib/devise/failure_app.rb +85 -25
- data/lib/devise/hooks/activatable.rb +5 -6
- data/lib/devise/hooks/csrf_cleaner.rb +7 -0
- data/lib/devise/hooks/forgetable.rb +1 -1
- data/lib/devise/hooks/lockable.rb +2 -2
- data/lib/devise/hooks/proxy.rb +21 -0
- data/lib/devise/hooks/rememberable.rb +5 -4
- data/lib/devise/hooks/timeoutable.rb +16 -8
- data/lib/devise/hooks/trackable.rb +1 -1
- data/lib/devise/mailers/helpers.rb +27 -23
- data/lib/devise/mapping.rb +11 -7
- data/lib/devise/models/authenticatable.rb +82 -66
- data/lib/devise/models/confirmable.rb +142 -55
- data/lib/devise/models/database_authenticatable.rb +59 -15
- data/lib/devise/models/lockable.rb +41 -30
- data/lib/devise/models/omniauthable.rb +3 -3
- data/lib/devise/models/recoverable.rb +56 -41
- data/lib/devise/models/rememberable.rb +65 -27
- data/lib/devise/models/timeoutable.rb +2 -8
- data/lib/devise/models/trackable.rb +6 -4
- data/lib/devise/models/validatable.rb +9 -9
- data/lib/devise/models.rb +4 -13
- data/lib/devise/modules.rb +10 -11
- data/lib/devise/omniauth/url_helpers.rb +2 -2
- data/lib/devise/orm/active_record.rb +1 -1
- data/lib/devise/orm/mongoid.rb +1 -1
- data/lib/devise/{param_filter.rb → parameter_filter.rb} +10 -11
- data/lib/devise/parameter_sanitizer.rb +99 -0
- data/lib/devise/rails/routes.rb +173 -115
- data/lib/devise/rails/warden_compat.rb +10 -31
- data/lib/devise/rails.rb +14 -12
- data/lib/devise/strategies/authenticatable.rb +26 -26
- data/lib/devise/strategies/base.rb +1 -1
- data/lib/devise/strategies/database_authenticatable.rb +8 -4
- data/lib/devise/strategies/rememberable.rb +15 -5
- data/lib/devise/test_helpers.rb +7 -5
- data/lib/devise/time_inflector.rb +14 -0
- data/lib/devise/token_generator.rb +70 -0
- data/lib/devise/version.rb +1 -1
- data/lib/devise.rb +110 -52
- data/lib/generators/active_record/devise_generator.rb +34 -18
- data/lib/generators/active_record/templates/migration.rb +5 -6
- data/lib/generators/active_record/templates/migration_existing.rb +5 -6
- data/lib/generators/devise/controllers_generator.rb +44 -0
- data/lib/generators/devise/devise_generator.rb +5 -3
- data/lib/generators/devise/install_generator.rb +5 -0
- data/lib/generators/devise/orm_helpers.rb +25 -6
- data/lib/generators/devise/views_generator.rb +52 -22
- data/lib/generators/mongoid/devise_generator.rb +21 -26
- data/lib/generators/templates/README +9 -5
- data/lib/generators/templates/controllers/README +14 -0
- data/lib/generators/templates/controllers/confirmations_controller.rb +28 -0
- data/lib/generators/templates/controllers/omniauth_callbacks_controller.rb +28 -0
- data/lib/generators/templates/controllers/passwords_controller.rb +32 -0
- data/lib/generators/templates/controllers/registrations_controller.rb +60 -0
- data/lib/generators/templates/controllers/sessions_controller.rb +25 -0
- data/lib/generators/templates/controllers/unlocks_controller.rb +28 -0
- data/lib/generators/templates/devise.rb +80 -43
- data/lib/generators/templates/markerb/confirmation_instructions.markerb +2 -2
- data/lib/generators/templates/markerb/password_change.markerb +3 -0
- data/lib/generators/templates/markerb/reset_password_instructions.markerb +1 -1
- data/lib/generators/templates/markerb/unlock_instructions.markerb +2 -2
- data/lib/generators/templates/simple_form_for/confirmations/new.html.erb +3 -2
- data/lib/generators/templates/simple_form_for/passwords/edit.html.erb +4 -4
- data/lib/generators/templates/simple_form_for/passwords/new.html.erb +2 -2
- data/lib/generators/templates/simple_form_for/registrations/edit.html.erb +11 -6
- data/lib/generators/templates/simple_form_for/registrations/new.html.erb +4 -4
- data/lib/generators/templates/simple_form_for/sessions/new.html.erb +6 -6
- data/lib/generators/templates/simple_form_for/unlocks/new.html.erb +3 -2
- data/script/cached-bundle +49 -0
- data/script/s3-put +71 -0
- data/test/controllers/custom_registrations_controller_test.rb +40 -0
- data/test/controllers/helper_methods_test.rb +21 -0
- data/test/controllers/helpers_test.rb +95 -32
- data/test/controllers/inherited_controller_i18n_messages_test.rb +51 -0
- data/test/controllers/internal_helpers_test.rb +39 -14
- data/test/controllers/load_hooks_controller_test.rb +19 -0
- data/test/controllers/passwords_controller_test.rb +31 -0
- data/test/controllers/sessions_controller_test.rb +66 -6
- data/test/controllers/url_helpers_test.rb +10 -4
- data/test/delegator_test.rb +1 -1
- data/test/devise_test.rb +45 -10
- data/test/failure_app_test.rb +121 -27
- data/test/generators/active_record_generator_test.rb +48 -8
- data/test/generators/controllers_generator_test.rb +48 -0
- data/test/generators/devise_generator_test.rb +2 -2
- data/test/generators/mongoid_generator_test.rb +3 -3
- data/test/generators/views_generator_test.rb +54 -3
- data/test/helpers/devise_helper_test.rb +18 -20
- data/test/integration/authenticatable_test.rb +161 -65
- data/test/integration/confirmable_test.rb +146 -77
- data/test/integration/database_authenticatable_test.rb +43 -30
- data/test/integration/http_authenticatable_test.rb +30 -22
- data/test/integration/lockable_test.rb +64 -49
- data/test/integration/omniauthable_test.rb +17 -15
- data/test/integration/recoverable_test.rb +111 -70
- data/test/integration/registerable_test.rb +114 -79
- data/test/integration/rememberable_test.rb +87 -31
- data/test/integration/timeoutable_test.rb +77 -33
- data/test/integration/trackable_test.rb +5 -5
- data/test/mailers/confirmation_instructions_test.rb +28 -8
- data/test/mailers/reset_password_instructions_test.rb +21 -8
- data/test/mailers/unlock_instructions_test.rb +20 -6
- data/test/mapping_test.rb +12 -5
- data/test/models/authenticatable_test.rb +17 -1
- data/test/models/confirmable_test.rb +216 -62
- data/test/models/database_authenticatable_test.rb +129 -49
- data/test/models/lockable_test.rb +132 -45
- data/test/models/recoverable_test.rb +100 -54
- data/test/models/rememberable_test.rb +89 -94
- data/test/models/serializable_test.rb +12 -11
- data/test/models/timeoutable_test.rb +6 -1
- data/test/models/trackable_test.rb +28 -0
- data/test/models/validatable_test.rb +31 -21
- data/test/models_test.rb +22 -48
- data/test/omniauth/config_test.rb +4 -4
- data/test/omniauth/url_helpers_test.rb +7 -4
- data/test/orm/active_record.rb +1 -0
- data/test/orm/mongoid.rb +2 -3
- data/test/parameter_sanitizer_test.rb +81 -0
- data/test/rails_app/Rakefile +0 -4
- data/test/rails_app/app/active_record/shim.rb +1 -1
- data/test/rails_app/app/active_record/user_on_engine.rb +7 -0
- data/test/rails_app/app/active_record/user_on_main_app.rb +7 -0
- data/test/rails_app/app/active_record/user_without_email.rb +8 -0
- data/test/rails_app/app/controllers/admins/sessions_controller.rb +1 -1
- data/test/rails_app/app/controllers/admins_controller.rb +0 -5
- data/test/rails_app/app/controllers/application_controller.rb +6 -2
- data/test/rails_app/app/controllers/application_with_fake_engine.rb +30 -0
- data/test/rails_app/app/controllers/custom/registrations_controller.rb +31 -0
- data/test/rails_app/app/controllers/home_controller.rb +1 -1
- data/test/rails_app/app/controllers/publisher/registrations_controller.rb +1 -1
- data/test/rails_app/app/controllers/publisher/sessions_controller.rb +1 -1
- data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +4 -4
- data/test/rails_app/app/controllers/users_controller.rb +12 -4
- data/test/rails_app/app/mailers/users/from_proc_mailer.rb +3 -0
- data/test/rails_app/app/mailers/users/mailer.rb +1 -1
- data/test/rails_app/app/mailers/users/reply_to_mailer.rb +4 -0
- data/test/rails_app/app/mongoid/admin.rb +12 -10
- data/test/rails_app/app/mongoid/shim.rb +4 -5
- data/test/rails_app/app/mongoid/user.rb +19 -22
- data/test/rails_app/app/mongoid/user_on_engine.rb +39 -0
- data/test/rails_app/app/mongoid/user_on_main_app.rb +39 -0
- data/test/rails_app/app/mongoid/user_without_email.rb +33 -0
- data/test/rails_app/app/views/admins/sessions/new.html.erb +1 -1
- data/test/rails_app/app/views/home/admin_dashboard.html.erb +1 -1
- data/test/rails_app/app/views/home/index.html.erb +1 -1
- data/test/rails_app/app/views/home/join.html.erb +1 -1
- data/test/rails_app/app/views/home/user_dashboard.html.erb +1 -1
- data/test/rails_app/app/views/layouts/application.html.erb +1 -1
- data/test/rails_app/app/views/users/edit_form.html.erb +1 -0
- data/test/rails_app/bin/bundle +3 -0
- data/test/rails_app/bin/rails +4 -0
- data/test/rails_app/bin/rake +4 -0
- data/test/rails_app/config/application.rb +4 -5
- data/test/rails_app/config/boot.rb +9 -3
- data/test/rails_app/config/environment.rb +2 -2
- data/test/rails_app/config/environments/development.rb +19 -7
- data/test/rails_app/config/environments/production.rb +68 -17
- data/test/rails_app/config/environments/test.rb +24 -16
- data/test/rails_app/config/initializers/devise.rb +22 -20
- data/test/rails_app/config/initializers/secret_token.rb +8 -2
- data/test/rails_app/config/initializers/session_store.rb +1 -0
- data/test/rails_app/config/routes.rb +71 -46
- data/test/rails_app/db/migrate/20100401102949_create_tables.rb +9 -12
- data/test/rails_app/db/schema.rb +21 -18
- data/test/rails_app/lib/shared_admin.rb +7 -4
- data/test/rails_app/lib/shared_user.rb +6 -3
- data/test/rails_app/lib/shared_user_without_email.rb +26 -0
- data/test/rails_app/lib/shared_user_without_omniauth.rb +13 -0
- data/test/rails_test.rb +9 -0
- data/test/routes_test.rb +94 -78
- data/test/support/action_controller/record_identifier.rb +10 -0
- data/test/support/assertions.rb +2 -3
- data/test/support/helpers.rb +18 -32
- data/test/support/integration.rb +17 -16
- data/test/support/locale/en.yml +4 -0
- data/test/support/mongoid.yml +6 -0
- data/test/test_helper.rb +8 -1
- data/test/test_helpers_test.rb +64 -20
- data/test/test_models.rb +33 -0
- data/test/time_helpers.rb +137 -0
- metadata +172 -51
- data/app/views/devise/_links.erb +0 -3
- data/gemfiles/Gemfile.rails-3.1.x +0 -35
- data/gemfiles/Gemfile.rails-3.1.x.lock +0 -167
- data/lib/devise/models/token_authenticatable.rb +0 -77
- data/lib/devise/strategies/token_authenticatable.rb +0 -56
- data/test/indifferent_hash.rb +0 -33
- data/test/integration/token_authenticatable_test.rb +0 -161
- data/test/models/token_authenticatable_test.rb +0 -55
- data/test/rails_app/script/rails +0 -10
@@ -6,11 +6,27 @@ class DeviseController < Devise.parent_controller.constantize
|
|
6
6
|
|
7
7
|
helpers = %w(resource scope_name resource_name signed_in_resource
|
8
8
|
resource_class resource_params devise_mapping)
|
9
|
-
|
10
|
-
helper_method *helpers
|
9
|
+
helper_method(*helpers)
|
11
10
|
|
12
11
|
prepend_before_filter :assert_is_devise_resource!
|
13
|
-
respond_to
|
12
|
+
respond_to :html if mimes_for_respond_to.empty?
|
13
|
+
|
14
|
+
# Override prefixes to consider the scoped view.
|
15
|
+
# Notice we need to check for the request due to a bug in
|
16
|
+
# Action Controller tests that forces _prefixes to be
|
17
|
+
# loaded before even having a request object.
|
18
|
+
#
|
19
|
+
# This method should be public as it is is in ActionPack
|
20
|
+
# itself. Changing its visibility may break other gems.
|
21
|
+
def _prefixes #:nodoc:
|
22
|
+
@_prefixes ||= if self.class.scoped_views? && request && devise_mapping
|
23
|
+
["#{devise_mapping.scoped_path}/#{controller_name}"] + super
|
24
|
+
else
|
25
|
+
super
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
protected
|
14
30
|
|
15
31
|
# Gets the actual resource stored in the instance variable
|
16
32
|
def resource
|
@@ -28,13 +44,9 @@ class DeviseController < Devise.parent_controller.constantize
|
|
28
44
|
devise_mapping.to
|
29
45
|
end
|
30
46
|
|
31
|
-
def resource_params
|
32
|
-
params[resource_name]
|
33
|
-
end
|
34
|
-
|
35
47
|
# Returns a signed in resource from session (if one exists)
|
36
48
|
def signed_in_resource
|
37
|
-
warden.authenticate(:
|
49
|
+
warden.authenticate(scope: resource_name)
|
38
50
|
end
|
39
51
|
|
40
52
|
# Attempt to find the mapped route for devise based on request path
|
@@ -42,22 +54,6 @@ class DeviseController < Devise.parent_controller.constantize
|
|
42
54
|
@devise_mapping ||= request.env["devise.mapping"]
|
43
55
|
end
|
44
56
|
|
45
|
-
# Override prefixes to consider the scoped view.
|
46
|
-
# Notice we need to check for the request due to a bug in
|
47
|
-
# Action Controller tests that forces _prefixes to be
|
48
|
-
# loaded before even having a request object.
|
49
|
-
def _prefixes #:nodoc:
|
50
|
-
@_prefixes ||= if self.class.scoped_views? && request && devise_mapping
|
51
|
-
super.unshift("#{devise_mapping.scoped_path}/#{controller_name}")
|
52
|
-
else
|
53
|
-
super
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
hide_action :_prefixes
|
58
|
-
|
59
|
-
protected
|
60
|
-
|
61
57
|
# Checks whether it's a devise mapped resource or not.
|
62
58
|
def assert_is_devise_resource! #:nodoc:
|
63
59
|
unknown_action! <<-MESSAGE unless devise_mapping
|
@@ -67,12 +63,12 @@ This may happen for two reasons:
|
|
67
63
|
1) You forgot to wrap your route inside the scope block. For example:
|
68
64
|
|
69
65
|
devise_scope :user do
|
70
|
-
|
66
|
+
get "/some/route" => "some_devise_controller"
|
71
67
|
end
|
72
68
|
|
73
69
|
2) You are testing a Devise controller bypassing the router.
|
74
70
|
If so, you can explicitly tell Devise which mapping to use:
|
75
|
-
|
71
|
+
|
76
72
|
@request.env["devise.mapping"] = Devise.mappings[:user]
|
77
73
|
|
78
74
|
MESSAGE
|
@@ -93,34 +89,17 @@ MESSAGE
|
|
93
89
|
instance_variable_set(:"@#{resource_name}", new_resource)
|
94
90
|
end
|
95
91
|
|
96
|
-
# Build a devise resource.
|
97
|
-
# Assignment bypasses attribute protection when :unsafe option is passed
|
98
|
-
def build_resource(hash = nil, options = {})
|
99
|
-
hash ||= resource_params || {}
|
100
|
-
|
101
|
-
if options[:unsafe]
|
102
|
-
self.resource = resource_class.new.tap do |resource|
|
103
|
-
hash.each do |key, value|
|
104
|
-
setter = :"#{key}="
|
105
|
-
resource.send(setter, value) if resource.respond_to?(setter)
|
106
|
-
end
|
107
|
-
end
|
108
|
-
else
|
109
|
-
self.resource = resource_class.new(hash)
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
92
|
# Helper for use in before_filters where no authentication is required.
|
114
93
|
#
|
115
94
|
# Example:
|
116
|
-
# before_filter :require_no_authentication, :
|
95
|
+
# before_filter :require_no_authentication, only: :new
|
117
96
|
def require_no_authentication
|
118
97
|
assert_is_devise_resource!
|
119
98
|
return unless is_navigational_format?
|
120
99
|
no_input = devise_mapping.no_input_strategies
|
121
100
|
|
122
101
|
authenticated = if no_input.present?
|
123
|
-
args = no_input.dup.push :
|
102
|
+
args = no_input.dup.push scope: resource_name
|
124
103
|
warden.authenticate?(*args)
|
125
104
|
else
|
126
105
|
warden.authenticated?(resource_name)
|
@@ -144,14 +123,17 @@ MESSAGE
|
|
144
123
|
end
|
145
124
|
|
146
125
|
if notice
|
147
|
-
set_flash_message :notice, notice if
|
126
|
+
set_flash_message :notice, notice if is_flashing_format?
|
148
127
|
true
|
149
128
|
end
|
150
129
|
end
|
151
130
|
|
152
131
|
# Sets the flash message with :key, using I18n. By default you are able
|
153
|
-
# to setup your messages using specific resource scope, and if no
|
154
|
-
# 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).
|
155
137
|
# Example (i18n locale file):
|
156
138
|
#
|
157
139
|
# en:
|
@@ -163,13 +145,40 @@ MESSAGE
|
|
163
145
|
#
|
164
146
|
# Please refer to README or en.yml locale file to check what messages are
|
165
147
|
# available.
|
166
|
-
def set_flash_message(key, kind, options={})
|
167
|
-
|
148
|
+
def set_flash_message(key, kind, options = {})
|
149
|
+
message = find_message(kind, options)
|
150
|
+
if options[:now]
|
151
|
+
flash.now[key] = message if message.present?
|
152
|
+
else
|
153
|
+
flash[key] = message if message.present?
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
# Sets minimum password length to show to user
|
158
|
+
def set_minimum_password_length
|
159
|
+
if devise_mapping.validatable?
|
160
|
+
@minimum_password_length = resource_class.password_length.min
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
def devise_i18n_options(options)
|
165
|
+
options
|
166
|
+
end
|
167
|
+
|
168
|
+
# Get message for given
|
169
|
+
def find_message(kind, options = {})
|
170
|
+
options[:scope] ||= translation_scope
|
168
171
|
options[:default] = Array(options[:default]).unshift(kind.to_sym)
|
169
172
|
options[:resource_name] = resource_name
|
170
|
-
options = devise_i18n_options(options)
|
171
|
-
|
172
|
-
|
173
|
+
options = devise_i18n_options(options)
|
174
|
+
I18n.t("#{options[:resource_name]}.#{kind}", options)
|
175
|
+
end
|
176
|
+
|
177
|
+
# Controllers inheriting DeviseController are advised to override this
|
178
|
+
# method so that other controllers inheriting from them would use
|
179
|
+
# existing translations.
|
180
|
+
def translation_scope
|
181
|
+
"devise.#{controller_name}"
|
173
182
|
end
|
174
183
|
|
175
184
|
def clean_up_passwords(object)
|
@@ -182,11 +191,9 @@ MESSAGE
|
|
182
191
|
end
|
183
192
|
end
|
184
193
|
|
185
|
-
def
|
186
|
-
|
194
|
+
def resource_params
|
195
|
+
params.fetch(resource_name, {})
|
187
196
|
end
|
188
197
|
|
189
|
-
|
190
|
-
Devise.navigational_formats.include?(request.format.try(:ref))
|
191
|
-
end
|
198
|
+
ActiveSupport.run_load_hooks(:devise_controller, self)
|
192
199
|
end
|
@@ -10,8 +10,8 @@ module DeviseHelper
|
|
10
10
|
|
11
11
|
messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
|
12
12
|
sentence = I18n.t("errors.messages.not_saved",
|
13
|
-
:
|
14
|
-
:
|
13
|
+
count: resource.errors.count,
|
14
|
+
resource: resource.class.model_name.human.downcase)
|
15
15
|
|
16
16
|
html = <<-HTML
|
17
17
|
<div id="error_explanation">
|
@@ -1,15 +1,24 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
if defined?(ActionMailer)
|
2
|
+
class Devise::Mailer < Devise.parent_mailer.constantize
|
3
|
+
include Devise::Mailers::Helpers
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
5
|
+
def confirmation_instructions(record, token, opts={})
|
6
|
+
@token = token
|
7
|
+
devise_mail(record, :confirmation_instructions, opts)
|
8
|
+
end
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
10
|
+
def reset_password_instructions(record, token, opts={})
|
11
|
+
@token = token
|
12
|
+
devise_mail(record, :reset_password_instructions, opts)
|
13
|
+
end
|
14
|
+
|
15
|
+
def unlock_instructions(record, token, opts={})
|
16
|
+
@token = token
|
17
|
+
devise_mail(record, :unlock_instructions, opts)
|
18
|
+
end
|
11
19
|
|
12
|
-
|
13
|
-
|
20
|
+
def password_change(record, opts={})
|
21
|
+
devise_mail(record, :password_change, opts)
|
22
|
+
end
|
14
23
|
end
|
15
24
|
end
|
@@ -1,12 +1,16 @@
|
|
1
1
|
<h2>Resend confirmation instructions</h2>
|
2
2
|
|
3
|
-
<%= form_for(resource, :
|
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, value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %>
|
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" %>
|
@@ -1,5 +1,5 @@
|
|
1
|
-
<p>Welcome <%= @
|
1
|
+
<p>Welcome <%= @email %>!</p>
|
2
2
|
|
3
3
|
<p>You can confirm your account email through the link below:</p>
|
4
4
|
|
5
|
-
<p><%= link_to 'Confirm my account', confirmation_url(@resource, :
|
5
|
+
<p><%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %></p>
|
@@ -1,8 +1,8 @@
|
|
1
1
|
<p>Hello <%= @resource.email %>!</p>
|
2
2
|
|
3
|
-
<p>Someone has requested a link to change your password
|
3
|
+
<p>Someone has requested a link to change your password. You can do this through the link below.</p>
|
4
4
|
|
5
|
-
<p><%= link_to 'Change my password', edit_password_url(@resource, :
|
5
|
+
<p><%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %></p>
|
6
6
|
|
7
7
|
<p>If you didn't request this, please ignore this email.</p>
|
8
8
|
<p>Your password won't change until you access the link above and create a new one.</p>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<p>Hello <%= @resource.email %>!</p>
|
2
2
|
|
3
|
-
<p>Your account has been locked due to an excessive
|
3
|
+
<p>Your account has been locked due to an excessive number of unsuccessful sign in attempts.</p>
|
4
4
|
|
5
5
|
<p>Click the link below to unlock your account:</p>
|
6
6
|
|
7
|
-
<p><%= link_to 'Unlock my account', unlock_url(@resource, :
|
7
|
+
<p><%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %></p>
|
@@ -1,16 +1,25 @@
|
|
1
1
|
<h2>Change your password</h2>
|
2
2
|
|
3
|
-
<%= form_for(resource, :
|
3
|
+
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %>
|
4
4
|
<%= devise_error_messages! %>
|
5
5
|
<%= f.hidden_field :reset_password_token %>
|
6
6
|
|
7
|
-
<div
|
8
|
-
|
7
|
+
<div class="field">
|
8
|
+
<%= f.label :password, "New password" %><br />
|
9
|
+
<% if @minimum_password_length %>
|
10
|
+
<em>(<%= @minimum_password_length %> characters minimum)</em><br />
|
11
|
+
<% end %>
|
12
|
+
<%= f.password_field :password, autofocus: true, autocomplete: "off" %>
|
13
|
+
</div>
|
9
14
|
|
10
|
-
<div
|
11
|
-
|
15
|
+
<div class="field">
|
16
|
+
<%= f.label :password_confirmation, "Confirm new password" %><br />
|
17
|
+
<%= f.password_field :password_confirmation, autocomplete: "off" %>
|
18
|
+
</div>
|
12
19
|
|
13
|
-
<div
|
20
|
+
<div class="actions">
|
21
|
+
<%= f.submit "Change my password" %>
|
22
|
+
</div>
|
14
23
|
<% end %>
|
15
24
|
|
16
25
|
<%= render "devise/shared/links" %>
|
@@ -1,12 +1,16 @@
|
|
1
1
|
<h2>Forgot your password?</h2>
|
2
2
|
|
3
|
-
<%= form_for(resource, :
|
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" %>
|
@@ -1,25 +1,39 @@
|
|
1
1
|
<h2>Edit <%= resource_name.to_s.humanize %></h2>
|
2
2
|
|
3
|
-
<%= form_for(resource, :
|
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
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
<div
|
16
|
-
|
17
|
-
|
18
|
-
|
6
|
+
<div class="field">
|
7
|
+
<%= f.label :email %><br />
|
8
|
+
<%= f.email_field :email, autofocus: true %>
|
9
|
+
</div>
|
10
|
+
|
11
|
+
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
|
12
|
+
<div>Currently waiting confirmation for: <%= resource.unconfirmed_email %></div>
|
13
|
+
<% end %>
|
14
|
+
|
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>
|
19
|
+
|
20
|
+
<div class="field">
|
21
|
+
<%= f.label :password_confirmation %><br />
|
22
|
+
<%= f.password_field :password_confirmation, autocomplete: "off" %>
|
23
|
+
</div>
|
24
|
+
|
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>
|
29
|
+
|
30
|
+
<div class="actions">
|
31
|
+
<%= f.submit "Update" %>
|
32
|
+
</div>
|
19
33
|
<% end %>
|
20
34
|
|
21
35
|
<h3>Cancel my account</h3>
|
22
36
|
|
23
|
-
<p>Unhappy? <%=
|
37
|
+
<p>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %></p>
|
24
38
|
|
25
39
|
<%= link_to "Back", :back %>
|
@@ -1,18 +1,29 @@
|
|
1
1
|
<h2>Sign up</h2>
|
2
2
|
|
3
|
-
<%= form_for(resource, :
|
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
|
-
|
11
|
+
<div class="field">
|
12
|
+
<%= f.label :password %>
|
13
|
+
<% if @minimum_password_length %>
|
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
|
-
|
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" %>
|