devise 1.1.pre4 → 1.1.rc0
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 +31 -2
- data/Gemfile +15 -6
- data/README.rdoc +12 -16
- data/Rakefile +2 -2
- data/TODO +2 -1
- data/app/controllers/devise/confirmations_controller.rb +1 -1
- data/app/controllers/devise/passwords_controller.rb +2 -3
- data/app/controllers/devise/registrations_controller.rb +5 -5
- data/app/controllers/devise/sessions_controller.rb +5 -27
- data/app/controllers/devise/unlocks_controller.rb +9 -1
- data/app/models/devise/mailer.rb +17 -11
- data/app/views/devise/confirmations/new.html.erb +1 -1
- data/app/views/devise/passwords/edit.html.erb +1 -1
- data/app/views/devise/passwords/new.html.erb +1 -1
- data/app/views/devise/registrations/edit.html.erb +2 -2
- data/app/views/devise/registrations/new.html.erb +2 -2
- data/app/views/devise/sessions/new.html.erb +2 -2
- data/app/views/devise/shared/_links.erb +5 -5
- data/app/views/devise/unlocks/new.html.erb +1 -1
- data/config/locales/en.yml +4 -9
- data/lib/devise.rb +83 -42
- data/lib/devise/controllers/helpers.rb +6 -18
- data/lib/devise/controllers/internal_helpers.rb +11 -12
- data/lib/devise/controllers/scoped_views.rb +2 -2
- data/lib/devise/controllers/url_helpers.rb +1 -1
- data/lib/devise/failure_app.rb +56 -16
- data/lib/devise/hooks/activatable.rb +18 -6
- data/lib/devise/hooks/rememberable.rb +36 -27
- data/lib/devise/hooks/timeoutable.rb +1 -1
- data/lib/devise/hooks/trackable.rb +4 -2
- data/lib/devise/mapping.rb +19 -14
- data/lib/devise/models.rb +12 -3
- data/lib/devise/models/authenticatable.rb +19 -95
- data/lib/devise/models/confirmable.rb +14 -20
- data/lib/devise/models/database_authenticatable.rb +99 -0
- data/lib/devise/models/lockable.rb +53 -39
- data/lib/devise/models/recoverable.rb +3 -3
- data/lib/devise/models/rememberable.rb +5 -10
- data/lib/devise/models/token_authenticatable.rb +18 -25
- data/lib/devise/models/validatable.rb +14 -9
- data/lib/devise/modules.rb +7 -8
- data/lib/devise/orm/active_record.rb +1 -1
- data/lib/devise/orm/data_mapper.rb +20 -7
- data/lib/devise/orm/mongoid.rb +40 -0
- data/lib/devise/rails.rb +26 -3
- data/lib/devise/rails/routes.rb +18 -16
- data/lib/devise/rails/warden_compat.rb +2 -2
- data/lib/devise/schema.rb +45 -18
- data/lib/devise/strategies/authenticatable.rb +92 -21
- data/lib/devise/strategies/base.rb +6 -3
- data/lib/devise/strategies/database_authenticatable.rb +20 -0
- data/lib/devise/strategies/rememberable.rb +10 -6
- data/lib/devise/strategies/token_authenticatable.rb +28 -19
- data/lib/devise/test_helpers.rb +5 -1
- data/lib/devise/version.rb +1 -1
- data/lib/generators/devise/devise_generator.rb +15 -5
- data/lib/generators/devise/templates/migration.rb +2 -2
- data/lib/generators/devise_install/templates/devise.rb +37 -16
- data/lib/generators/devise_views/devise_views_generator.rb +51 -4
- data/test/controllers/helpers_test.rb +16 -8
- data/test/controllers/internal_helpers_test.rb +6 -1
- data/test/controllers/url_helpers_test.rb +10 -10
- data/test/devise_test.rb +13 -17
- data/test/encryptors_test.rb +2 -0
- data/test/failure_app_test.rb +72 -23
- data/test/integration/confirmable_test.rb +4 -4
- data/test/integration/{authenticatable_test.rb → database_authenticatable_test.rb} +35 -17
- data/test/integration/http_authenticatable_test.rb +3 -3
- data/test/integration/lockable_test.rb +28 -8
- data/test/integration/recoverable_test.rb +3 -3
- data/test/integration/registerable_test.rb +6 -4
- data/test/integration/rememberable_test.rb +11 -4
- data/test/integration/timeoutable_test.rb +4 -4
- data/test/integration/token_authenticatable_test.rb +46 -10
- data/test/integration/trackable_test.rb +2 -2
- data/test/mailers/confirmation_instructions_test.rb +5 -5
- data/test/mailers/reset_password_instructions_test.rb +5 -5
- data/test/mailers/unlock_instructions_test.rb +5 -5
- data/test/mapping_test.rb +15 -14
- data/test/models/confirmable_test.rb +9 -32
- data/test/models/{authenticatable_test.rb → database_authenticatable_test.rb} +2 -34
- data/test/models/lockable_test.rb +48 -66
- data/test/models/recoverable_test.rb +8 -8
- data/test/models/rememberable_test.rb +6 -28
- data/test/models/timeoutable_test.rb +1 -1
- data/test/models/token_authenticatable_test.rb +1 -8
- data/test/models/trackable_test.rb +1 -1
- data/test/models/validatable_test.rb +2 -2
- data/test/models_test.rb +16 -2
- data/test/orm/active_record.rb +1 -22
- data/test/orm/data_mapper.rb +1 -0
- data/test/orm/mongoid.rb +10 -0
- data/test/rails_app/app/active_record/admin.rb +1 -5
- data/test/rails_app/app/controllers/application_controller.rb +2 -0
- data/test/rails_app/app/controllers/sessions_controller.rb +1 -1
- data/test/rails_app/app/data_mapper/admin.rb +13 -0
- data/test/rails_app/app/data_mapper/user.rb +24 -0
- data/test/rails_app/app/mongoid/admin.rb +15 -0
- data/test/rails_app/app/mongoid/user.rb +21 -0
- data/test/rails_app/config/application.rb +10 -5
- data/test/rails_app/config/boot.rb +5 -1
- data/test/rails_app/config/initializers/devise.rb +1 -1
- data/test/rails_app/config/routes.rb +4 -1
- data/test/rails_app/db/migrate/20100401102949_create_tables.rb +27 -0
- data/test/rails_app/db/schema.rb +86 -0
- data/test/routes_test.rb +3 -3
- data/test/support/assertions.rb +2 -0
- data/test/support/helpers.rb +2 -0
- data/test/support/integration.rb +4 -7
- data/test/support/webrat/integrations/rails.rb +2 -1
- data/test/test_helper.rb +5 -2
- data/test/test_helpers_test.rb +4 -4
- metadata +36 -21
- data/lib/devise/models/http_authenticatable.rb +0 -19
- data/lib/devise/orm/mongo_mapper.rb +0 -49
- data/lib/devise/strategies/http_authenticatable.rb +0 -47
- data/test/models/http_authenticatable_test.rb +0 -19
- data/test/orm/mongo_mapper.rb +0 -12
- data/test/rails_app/app/mongo_mapper/admin.rb +0 -10
- data/test/rails_app/app/mongo_mapper/user.rb +0 -11
- data/test/rails_app/config/initializers/cookie_verification_secret.rb +0 -7
- data/test/rails_app/config/initializers/session_store.rb +0 -15
data/CHANGELOG.rdoc
CHANGED
@@ -3,17 +3,46 @@
|
|
3
3
|
* enhancements
|
4
4
|
* Rails 3 compatibility.
|
5
5
|
* All controllers and views are namespaced, for example: Devise::SessionsController and "devise/sessions".
|
6
|
-
* You can specify the controller in routes and have specific controllers for each role.
|
7
6
|
* Devise.orm is deprecated. This reduces the required API to hook your ORM with devise.
|
8
7
|
* Use metal for failure app.
|
9
8
|
* HTML e-mails now have proper formatting.
|
10
|
-
* Do not remove options from Datamapper and MongoMapper in find
|
9
|
+
* Do not remove options from Datamapper and MongoMapper in find.
|
10
|
+
* Allow to give :skip and :controllers in routes.
|
11
|
+
* Move trackable logic to the model.
|
12
|
+
* E-mails now use any template available in the filesystem. Easy to create multipart e-mails.
|
13
|
+
* E-mails asks headers_for in the model to set the proper headers.
|
14
|
+
* Allow to specify haml in devise_views.
|
15
|
+
* Compatibility with Datamapper and Mongoid.
|
16
|
+
* Make config.devise available on config/application.rb.
|
17
|
+
* TokenAuthenticatable now works with HTTP Basic Auth.
|
18
|
+
* 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.
|
19
|
+
* No need to append ?unauthenticated=true in URLs anymore since Flash was moved to a middleware in Rails 3.
|
20
|
+
* All messages under devise.sessions, except :signed_in and :signed_out, should be moved to devise.failure.
|
21
|
+
|
22
|
+
* bug fix
|
23
|
+
* Do not allow unlockable strategies based on time to access a controller.
|
24
|
+
* Do not send unlockable email several times.
|
11
25
|
|
12
26
|
* deprecations
|
13
27
|
* Rails 3 compatible only.
|
14
28
|
* Scoped views are no longer "sessions/users/new". Now use "users/sessions/new".
|
15
29
|
* Devise.orm is deprecated, just require "devise/orm/YOUR_ORM" instead.
|
16
30
|
* Devise.default_url_options is deprecated, just modify ApplicationController.default_url_options.
|
31
|
+
* All messages under devise.sessions, except :signed_in and :signed_out, should be moved to devise.failure.
|
32
|
+
|
33
|
+
== 1.0.5
|
34
|
+
|
35
|
+
* bug fix
|
36
|
+
* Use prepend_before_filter in require_no_authentication.
|
37
|
+
* require_no_authentication on unlockable.
|
38
|
+
* Fix a bug when giving an association proxy to devise.
|
39
|
+
* Do not use lock! on lockable since it's part of ActiveRecord API.
|
40
|
+
|
41
|
+
== 1.0.4
|
42
|
+
|
43
|
+
* bug fix
|
44
|
+
* Fixed a bug when deleting an account with rememberable
|
45
|
+
* Fixed a bug with custom controllers
|
17
46
|
|
18
47
|
== 1.0.3
|
19
48
|
|
data/Gemfile
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
source "http://gemcutter.org"
|
2
2
|
|
3
|
-
|
4
|
-
gem "
|
3
|
+
# Need to install Rails from source
|
4
|
+
gem "rails", "3.0.0.beta2"
|
5
|
+
gem "warden", "0.10.3"
|
5
6
|
gem "sqlite3-ruby", :require => "sqlite3"
|
6
7
|
gem "webrat", "0.7"
|
7
8
|
gem "mocha", :require => false
|
@@ -11,8 +12,16 @@ if RUBY_VERSION < '1.9'
|
|
11
12
|
gem "ruby-debug", ">= 0.10.3"
|
12
13
|
end
|
13
14
|
|
14
|
-
group :
|
15
|
-
gem "mongo", "0.18.3"
|
16
|
-
gem "mongo_ext", "0.18.3", :require => false
|
17
|
-
gem "
|
15
|
+
group :mongoid do
|
16
|
+
gem "mongo", ">= 0.18.3"
|
17
|
+
gem "mongo_ext", ">= 0.18.3", :require => false
|
18
|
+
gem "mongoid", :git => "git://github.com/durran/mongoid.git"
|
18
19
|
end
|
20
|
+
|
21
|
+
group :data_mapper do
|
22
|
+
gem "do_sqlite3", '>= 0.10.1'
|
23
|
+
gem "dm-core", :git => "git://github.com/datamapper/dm-core.git"
|
24
|
+
gem "dm-validations", :git => "git://github.com/datamapper/dm-more.git"
|
25
|
+
gem "dm-timestamps", :git => "git://github.com/datamapper/dm-more.git"
|
26
|
+
gem "dm-rails", :git => "git://github.com/datamapper/dm-rails.git"
|
27
|
+
end
|
data/README.rdoc
CHANGED
@@ -7,11 +7,10 @@ Devise is a flexible authentication solution for Rails based on Warden. It:
|
|
7
7
|
* Allows you to have multiple roles (or models/scopes) signed in at the same time;
|
8
8
|
* Is based on a modularity concept: use just what you really need.
|
9
9
|
|
10
|
-
Right now it's composed of
|
10
|
+
Right now it's composed of 11 modules:
|
11
11
|
|
12
|
-
* Authenticatable: encrypts a password
|
13
|
-
* Token Authenticatable:
|
14
|
-
* HttpAuthenticatable: sign in users using basic HTTP authentication.
|
12
|
+
* Database Authenticatable: encrypts and stores a password in the database to validate the authenticity of an user while signing in. The authentication can be done both through POST requests or HTTP Basic Authentication.
|
13
|
+
* Token Authenticatable: signs in an user based on an authentication token (also known as "single access token"). The token can be given both through query string or HTTP Basic Authentication.
|
15
14
|
* Confirmable: sends emails with confirmation instructions and verifies whether an account is already confirmed during sign in.
|
16
15
|
* Recoverable: resets the user password and sends reset instructions.
|
17
16
|
* Registerable: handles signing up users through a registration process.
|
@@ -33,18 +32,13 @@ Devise is based on Warden (http://github.com/hassox/warden), a Rack Authenticati
|
|
33
32
|
|
34
33
|
== Installation
|
35
34
|
|
36
|
-
Devise master branch now supports Rails 3 and is NOT backward compatible.
|
35
|
+
Devise master branch now supports Rails 3 and is NOT backward compatible. If you are using Rails 3.0.0 beta gem, you need to install devise as a gem:
|
37
36
|
|
38
|
-
sudo gem install devise --version=1.1.
|
37
|
+
sudo gem install devise --version=1.1.pre4
|
39
38
|
|
40
|
-
|
39
|
+
However, if you are using Rails edge, from the git repository, you also need to use Devise from the git repository. After you install Devise and add it to your gemfile, you need to run the generator:
|
41
40
|
|
42
|
-
|
43
|
-
gem 'devise'
|
44
|
-
|
45
|
-
And run the generator:
|
46
|
-
|
47
|
-
rails generate devise_install
|
41
|
+
rails generate devise_install
|
48
42
|
|
49
43
|
And you're ready to go. The generator will install an initializer which describes ALL Devise's configuration options, so be sure to take a look at it and at the documentation as well:
|
50
44
|
|
@@ -54,7 +48,7 @@ And you're ready to go. The generator will install an initializer which describe
|
|
54
48
|
|
55
49
|
If you want to use the Rails 2.3.x version, you should do:
|
56
50
|
|
57
|
-
sudo gem install devise --version=1.0.
|
51
|
+
sudo gem install devise --version=1.0.4
|
58
52
|
|
59
53
|
Or checkout from the v1.0 branch:
|
60
54
|
|
@@ -256,7 +250,7 @@ Devise implements encryption strategies for Clearance, Authlogic and Restful-Aut
|
|
256
250
|
|
257
251
|
== Other ORMs
|
258
252
|
|
259
|
-
Devise supports ActiveRecord (by default) and
|
253
|
+
Devise supports ActiveRecord (by default) and Mongoid. We offer experimental Datamapper support (with the limitation that the Devise test suite does not run completely with Datamapper). To choose other ORM, you just need to configure it in the initializer file.
|
260
254
|
|
261
255
|
== TODO
|
262
256
|
|
@@ -271,12 +265,14 @@ Please refer to TODO file.
|
|
271
265
|
|
272
266
|
We have a long list of valued contributors. See the CHANGELOG or do `git shortlog -s -n` in the cloned repository.
|
273
267
|
|
274
|
-
==
|
268
|
+
== Devise extensions
|
275
269
|
|
276
270
|
* http://github.com/scambra/devise_invitable adds support to Devise for sending invitations by email.
|
277
271
|
|
278
272
|
* http://github.com/grimen/devise_facebook_connectable adds support for Facebook Connect authentication, and optionally fetching user info from Facebook in the same step.
|
279
273
|
|
274
|
+
* http://github.com/joshk/devise_imapable adds support for imap based authentication, excellent for internal apps when an LDAP server isn't available.
|
275
|
+
|
280
276
|
== Bugs and Feedback
|
281
277
|
|
282
278
|
If you discover any bugs, please create an issue on GitHub.
|
data/Rakefile
CHANGED
@@ -37,7 +37,7 @@ begin
|
|
37
37
|
require 'jeweler'
|
38
38
|
Jeweler::Tasks.new do |s|
|
39
39
|
s.name = "devise"
|
40
|
-
s.version = Devise::VERSION
|
40
|
+
s.version = Devise::VERSION.dup
|
41
41
|
s.summary = "Flexible authentication solution for Rails with Warden"
|
42
42
|
s.email = "contact@plataformatec.com.br"
|
43
43
|
s.homepage = "http://github.com/plataformatec/devise"
|
@@ -45,7 +45,7 @@ begin
|
|
45
45
|
s.authors = ['José Valim', 'Carlos Antônio']
|
46
46
|
s.files = FileList["[A-Z]*", "{app,config,lib}/**/*"]
|
47
47
|
s.extra_rdoc_files = FileList["[A-Z]*"] - %w(Gemfile Rakefile)
|
48
|
-
s.add_dependency("warden", "~> 0.
|
48
|
+
s.add_dependency("warden", "~> 0.10.3")
|
49
49
|
end
|
50
50
|
|
51
51
|
Jeweler::GemcutterTasks.new
|
data/TODO
CHANGED
@@ -21,7 +21,7 @@ class Devise::ConfirmationsController < ApplicationController
|
|
21
21
|
|
22
22
|
# GET /resource/confirmation?confirmation_token=abcdef
|
23
23
|
def show
|
24
|
-
self.resource = resource_class.
|
24
|
+
self.resource = resource_class.confirm_by_token(params[:confirmation_token])
|
25
25
|
|
26
26
|
if resource.errors.empty?
|
27
27
|
set_flash_message :notice, :confirmed
|
@@ -1,8 +1,7 @@
|
|
1
1
|
class Devise::PasswordsController < ApplicationController
|
2
|
+
prepend_before_filter :require_no_authentication
|
2
3
|
include Devise::Controllers::InternalHelpers
|
3
4
|
|
4
|
-
before_filter :require_no_authentication
|
5
|
-
|
6
5
|
# GET /resource/password/new
|
7
6
|
def new
|
8
7
|
build_resource
|
@@ -30,7 +29,7 @@ class Devise::PasswordsController < ApplicationController
|
|
30
29
|
|
31
30
|
# PUT /resource/password
|
32
31
|
def update
|
33
|
-
self.resource = resource_class.
|
32
|
+
self.resource = resource_class.reset_password_by_token(params[resource_name])
|
34
33
|
|
35
34
|
if resource.errors.empty?
|
36
35
|
set_flash_message :notice, :updated
|
@@ -1,12 +1,11 @@
|
|
1
1
|
class Devise::RegistrationsController < ApplicationController
|
2
|
+
prepend_before_filter :require_no_authentication, :only => [ :new, :create ]
|
3
|
+
prepend_before_filter :authenticate_scope!, :only => [:edit, :update, :destroy]
|
2
4
|
include Devise::Controllers::InternalHelpers
|
3
5
|
|
4
|
-
before_filter :require_no_authentication, :only => [ :new, :create ]
|
5
|
-
before_filter :authenticate_scope!, :only => [:edit, :update, :destroy]
|
6
|
-
|
7
6
|
# GET /resource/sign_up
|
8
7
|
def new
|
9
|
-
build_resource
|
8
|
+
build_resource({})
|
10
9
|
render_with_scope :new
|
11
10
|
end
|
12
11
|
|
@@ -15,10 +14,10 @@ class Devise::RegistrationsController < ApplicationController
|
|
15
14
|
build_resource
|
16
15
|
|
17
16
|
if resource.save
|
18
|
-
flash[:"#{resource_name}_signed_up"] = true
|
19
17
|
set_flash_message :notice, :signed_up
|
20
18
|
sign_in_and_redirect(resource_name, resource)
|
21
19
|
else
|
20
|
+
clean_up_passwords(resource)
|
22
21
|
render_with_scope :new
|
23
22
|
end
|
24
23
|
end
|
@@ -34,6 +33,7 @@ class Devise::RegistrationsController < ApplicationController
|
|
34
33
|
set_flash_message :notice, :updated
|
35
34
|
redirect_to after_sign_in_path_for(self.resource)
|
36
35
|
else
|
36
|
+
clean_up_passwords(resource)
|
37
37
|
render_with_scope :edit
|
38
38
|
end
|
39
39
|
end
|
@@ -1,30 +1,18 @@
|
|
1
1
|
class Devise::SessionsController < ApplicationController
|
2
|
+
prepend_before_filter :require_no_authentication, :only => [ :new, :create ]
|
2
3
|
include Devise::Controllers::InternalHelpers
|
3
4
|
|
4
|
-
before_filter :require_no_authentication, :only => [ :new, :create ]
|
5
|
-
|
6
5
|
# GET /resource/sign_in
|
7
6
|
def new
|
8
|
-
|
9
|
-
Devise::FLASH_MESSAGES.each do |message|
|
10
|
-
set_now_flash_message :alert, message if params.try(:[], message) == "true"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
build_resource
|
7
|
+
clean_up_passwords(build_resource)
|
15
8
|
render_with_scope :new
|
16
9
|
end
|
17
10
|
|
18
11
|
# POST /resource/sign_in
|
19
12
|
def create
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
else
|
24
|
-
set_now_flash_message :alert, (warden.message || :invalid)
|
25
|
-
clean_up_passwords(build_resource)
|
26
|
-
render_with_scope :new
|
27
|
-
end
|
13
|
+
resource = warden.authenticate!(:scope => resource_name, :recall => "new")
|
14
|
+
set_flash_message :notice, :signed_in
|
15
|
+
sign_in_and_redirect(resource_name, resource)
|
28
16
|
end
|
29
17
|
|
30
18
|
# GET /resource/sign_out
|
@@ -32,14 +20,4 @@ class Devise::SessionsController < ApplicationController
|
|
32
20
|
set_flash_message :notice, :signed_out if signed_in?(resource_name)
|
33
21
|
sign_out_and_redirect(resource_name)
|
34
22
|
end
|
35
|
-
|
36
|
-
protected
|
37
|
-
|
38
|
-
def resource_just_signed_up?
|
39
|
-
flash[:"#{resource_name}_signed_up"]
|
40
|
-
end
|
41
|
-
|
42
|
-
def clean_up_passwords(object)
|
43
|
-
object.clean_up_passwords if object.respond_to?(:clean_up_passwords)
|
44
|
-
end
|
45
23
|
end
|
@@ -1,4 +1,6 @@
|
|
1
1
|
class Devise::UnlocksController < ApplicationController
|
2
|
+
prepend_before_filter :ensure_email_as_unlock_strategy
|
3
|
+
prepend_before_filter :require_no_authentication
|
2
4
|
include Devise::Controllers::InternalHelpers
|
3
5
|
|
4
6
|
# GET /resource/unlock/new
|
@@ -21,7 +23,7 @@ class Devise::UnlocksController < ApplicationController
|
|
21
23
|
|
22
24
|
# GET /resource/unlock?unlock_token=abcdef
|
23
25
|
def show
|
24
|
-
self.resource = resource_class.
|
26
|
+
self.resource = resource_class.unlock_access_by_token(params[:unlock_token])
|
25
27
|
|
26
28
|
if resource.errors.empty?
|
27
29
|
set_flash_message :notice, :unlocked
|
@@ -30,4 +32,10 @@ class Devise::UnlocksController < ApplicationController
|
|
30
32
|
render_with_scope :new
|
31
33
|
end
|
32
34
|
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
|
33
41
|
end
|
data/app/models/devise/mailer.rb
CHANGED
@@ -19,21 +19,27 @@ class Devise::Mailer < ::ActionMailer::Base
|
|
19
19
|
|
20
20
|
# Configure default email options
|
21
21
|
def setup_mail(record, action)
|
22
|
-
@
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
22
|
+
@scope_name = Devise::Mapping.find_scope!(record)
|
23
|
+
@devise_mapping = Devise.mappings[@scope_name]
|
24
|
+
@resource = instance_variable_set("@#{@devise_mapping.name}", record)
|
25
|
+
|
26
|
+
template_path = ["devise/mailer"]
|
27
|
+
template_path.unshift "#{@devise_mapping.as}/mailer" if self.class.scoped_views?
|
28
|
+
|
29
|
+
headers = {
|
30
|
+
:subject => translate(@devise_mapping, action),
|
31
|
+
:from => mailer_sender(@devise_mapping),
|
32
|
+
:to => record.email,
|
33
|
+
:template_path => template_path
|
34
|
+
}
|
35
|
+
|
36
|
+
headers.merge!(record.headers_for(action)) if record.respond_to?(:headers_for)
|
37
|
+
mail(headers)
|
31
38
|
end
|
32
39
|
|
33
40
|
def mailer_sender(mapping)
|
34
41
|
if Devise.mailer_sender.is_a?(Proc)
|
35
|
-
|
36
|
-
Devise.mailer_sender.call(block_args)
|
42
|
+
Devise.mailer_sender.call(mapping.name)
|
37
43
|
else
|
38
44
|
Devise.mailer_sender
|
39
45
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<h2>Resend confirmation instructions</h2>
|
2
2
|
|
3
|
-
|
3
|
+
<%= form_for(resource_name, resource, :url => confirmation_path(resource_name)) do |f| %>
|
4
4
|
<%= f.error_messages %>
|
5
5
|
|
6
6
|
<p><%= f.label :email %></p>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<h2>Change your password</h2>
|
2
2
|
|
3
|
-
|
3
|
+
<%= form_for(resource_name, resource, :url => password_path(resource_name), :html => { :method => :put }) do |f| %>
|
4
4
|
<%= f.error_messages %>
|
5
5
|
<%= f.hidden_field :reset_password_token %>
|
6
6
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<h2>Edit <%= resource_name.to_s.humanize %></h2>
|
2
2
|
|
3
|
-
|
3
|
+
<%= form_for(resource_name, resource, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
|
4
4
|
<%= f.error_messages %>
|
5
5
|
|
6
6
|
<p><%= f.label :email %></p>
|
@@ -16,7 +16,7 @@
|
|
16
16
|
<p><%= f.password_field :current_password %></p>
|
17
17
|
|
18
18
|
<p><%= f.submit "Update" %></p>
|
19
|
-
<% end
|
19
|
+
<% end %>
|
20
20
|
|
21
21
|
<h3>Cancel my account</h3>
|
22
22
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<h2>Sign up</h2>
|
2
2
|
|
3
|
-
|
3
|
+
<%= form_for(resource_name, resource, :url => registration_path(resource_name)) do |f| %>
|
4
4
|
<%= f.error_messages %>
|
5
5
|
<p><%= f.label :email %></p>
|
6
6
|
<p><%= f.text_field :email %></p>
|
@@ -12,6 +12,6 @@
|
|
12
12
|
<p><%= f.password_field :password_confirmation %></p>
|
13
13
|
|
14
14
|
<p><%= f.submit "Sign up" %></p>
|
15
|
-
<% end
|
15
|
+
<% end %>
|
16
16
|
|
17
17
|
<%= render :partial => "devise/shared/links" %>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<h2>Sign in</h2>
|
2
2
|
|
3
|
-
|
3
|
+
<%= form_for(resource_name, resource, :url => session_path(resource_name)) do |f| %>
|
4
4
|
<p><%= f.label :email %></p>
|
5
5
|
<p><%= f.text_field :email %></p>
|
6
6
|
|
@@ -12,6 +12,6 @@
|
|
12
12
|
<% end -%>
|
13
13
|
|
14
14
|
<p><%= f.submit "Sign in" %></p>
|
15
|
-
<% end
|
15
|
+
<% end %>
|
16
16
|
|
17
17
|
<%= render :partial => "devise/shared/links" %>
|
@@ -1,19 +1,19 @@
|
|
1
1
|
<%- if controller_name != 'sessions' %>
|
2
|
-
<%= link_to
|
2
|
+
<%= link_to "Sign in", new_session_path(resource_name) %><br />
|
3
3
|
<% end -%>
|
4
4
|
|
5
5
|
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
|
6
|
-
<%= link_to
|
6
|
+
<%= link_to "Sign up", new_registration_path(resource_name) %><br />
|
7
7
|
<% end -%>
|
8
8
|
|
9
9
|
<%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
|
10
|
-
<%= link_to
|
10
|
+
<%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
|
11
11
|
<% end -%>
|
12
12
|
|
13
13
|
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
|
14
|
-
<%= link_to t
|
14
|
+
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
|
15
15
|
<% end -%>
|
16
16
|
|
17
17
|
<%- if devise_mapping.lockable? && controller_name != 'unlocks' %>
|
18
|
-
<%= link_to t
|
18
|
+
<%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
|
19
19
|
<% end -%>
|