devise 1.1.rc1 → 1.1.rc2
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 +63 -27
- data/Gemfile +15 -13
- data/README.rdoc +63 -51
- data/Rakefile +3 -2
- data/TODO +1 -0
- data/app/controllers/devise/registrations_controller.rb +1 -1
- data/app/mailers/devise/mailer.rb +43 -43
- data/app/views/devise/confirmations/new.html.erb +2 -2
- data/app/views/devise/passwords/edit.html.erb +4 -4
- data/app/views/devise/passwords/new.html.erb +2 -2
- data/app/views/devise/registrations/edit.html.erb +8 -8
- data/app/views/devise/registrations/new.html.erb +6 -6
- data/app/views/devise/sessions/new.html.erb +4 -4
- data/app/views/devise/unlocks/new.html.erb +2 -2
- data/config/locales/en.yml +7 -4
- data/lib/devise.rb +33 -6
- data/lib/devise/controllers/helpers.rb +38 -2
- data/lib/devise/encryptors/authlogic_sha512.rb +0 -2
- data/lib/devise/encryptors/bcrypt.rb +0 -2
- data/lib/devise/encryptors/clearance_sha1.rb +0 -2
- data/lib/devise/encryptors/sha1.rb +6 -8
- data/lib/devise/encryptors/sha512.rb +6 -8
- data/lib/devise/failure_app.rb +3 -2
- data/lib/devise/hooks/activatable.rb +4 -1
- data/lib/devise/hooks/forgetable.rb +4 -3
- data/lib/devise/hooks/rememberable.rb +6 -2
- data/lib/devise/hooks/timeoutable.rb +6 -2
- data/lib/devise/mapping.rb +7 -8
- data/lib/devise/models.rb +0 -34
- data/lib/devise/models/authenticatable.rb +29 -3
- data/lib/devise/models/confirmable.rb +3 -2
- data/lib/devise/models/database_authenticatable.rb +4 -2
- data/lib/devise/models/lockable.rb +1 -1
- data/lib/devise/models/recoverable.rb +1 -1
- data/lib/devise/models/rememberable.rb +9 -1
- data/lib/devise/orm/active_record.rb +4 -6
- data/lib/devise/orm/data_mapper.rb +5 -7
- data/lib/devise/orm/mongoid.rb +2 -13
- data/lib/devise/path_checker.rb +13 -0
- data/lib/devise/rails.rb +45 -18
- data/lib/devise/rails/routes.rb +24 -7
- data/lib/devise/schema.rb +23 -19
- data/lib/devise/strategies/authenticatable.rb +20 -4
- data/lib/devise/strategies/database_authenticatable.rb +1 -1
- data/lib/devise/strategies/token_authenticatable.rb +2 -2
- data/lib/devise/test_helpers.rb +2 -1
- data/lib/devise/version.rb +1 -1
- data/lib/generators/devise/devise/devise_generator.rb +86 -0
- data/lib/generators/devise/{templates → devise/templates}/migration.rb +2 -2
- data/lib/generators/devise/install/install_generator.rb +24 -0
- data/lib/generators/{devise_install → devise/install}/templates/README +1 -1
- data/lib/generators/{devise_install → devise/install}/templates/devise.rb +37 -18
- data/lib/generators/devise/views/views_generator.rb +63 -0
- data/lib/generators/devise_generator.rb +2 -0
- data/lib/generators/devise_install_generator.rb +4 -0
- data/lib/generators/devise_views_generator.rb +4 -0
- data/test/controllers/helpers_test.rb +15 -0
- data/test/devise_test.rb +1 -0
- data/test/failure_app_test.rb +25 -10
- data/test/integration/authenticatable_test.rb +279 -0
- data/test/integration/database_authenticatable_test.rb +2 -262
- data/test/integration/http_authenticatable_test.rb +7 -9
- data/test/integration/registerable_test.rb +14 -2
- data/test/integration/rememberable_test.rb +15 -3
- data/test/integration/timeoutable_test.rb +12 -0
- data/test/integration/token_authenticatable_test.rb +2 -3
- data/test/mailers/confirmation_instructions_test.rb +2 -2
- data/test/mailers/reset_password_instructions_test.rb +2 -2
- data/test/mailers/unlock_instructions_test.rb +3 -3
- data/test/models/confirmable_test.rb +16 -0
- data/test/models/database_authenticatable_test.rb +20 -20
- data/test/models/lockable_test.rb +1 -1
- data/test/models/rememberable_test.rb +4 -4
- data/test/orm/data_mapper.rb +9 -0
- data/test/rails_app/app/active_record/shim.rb +2 -0
- data/test/rails_app/app/controllers/application_controller.rb +1 -0
- data/test/rails_app/app/controllers/home_controller.rb +3 -0
- data/test/rails_app/app/controllers/users_controller.rb +2 -0
- data/test/rails_app/app/data_mapper/shim.rb +2 -0
- data/test/rails_app/app/data_mapper/user.rb +4 -5
- data/test/rails_app/app/mongoid/admin.rb +1 -10
- data/test/rails_app/app/mongoid/shim.rb +16 -0
- data/test/rails_app/app/mongoid/user.rb +1 -12
- data/test/rails_app/config/application.rb +2 -0
- data/test/rails_app/config/initializers/devise.rb +2 -2
- data/test/rails_app/config/routes.rb +6 -1
- data/test/routes_test.rb +2 -2
- data/test/test_helper.rb +0 -4
- data/test/test_helpers_test.rb +1 -0
- metadata +113 -12
- data/lib/generators/devise/devise_generator.rb +0 -67
- data/lib/generators/devise_install/devise_install_generator.rb +0 -25
- data/lib/generators/devise_views/devise_views_generator.rb +0 -62
data/CHANGELOG.rdoc
CHANGED
@@ -1,34 +1,70 @@
|
|
1
|
-
== 1.1.
|
2
|
-
|
3
|
-
* enhancements
|
4
|
-
*
|
5
|
-
*
|
6
|
-
*
|
7
|
-
*
|
8
|
-
*
|
9
|
-
|
10
|
-
|
11
|
-
*
|
12
|
-
|
13
|
-
|
14
|
-
*
|
15
|
-
*
|
16
|
-
*
|
17
|
-
*
|
18
|
-
|
19
|
-
|
20
|
-
|
1
|
+
== 1.1.rc2
|
2
|
+
|
3
|
+
* enhancements
|
4
|
+
* Allow to set cookie domain for the remember token. (by github.com/mantas)
|
5
|
+
* Added navigational formats to specify when it should return a 302 and when a 401.
|
6
|
+
* Added authenticate(scope) support in routes (by github.com/wildchild)
|
7
|
+
* Added after_update_path_for to registrations controller (by github.com/thedelchop)
|
8
|
+
* Allow the mailer object to be replaced through config.mailer = "MyOwnMailer"
|
9
|
+
|
10
|
+
* bug fix
|
11
|
+
* Fix a bug where session was timing out on sign out
|
12
|
+
|
13
|
+
* deprecations
|
14
|
+
* bcrypt is now the default encryptor
|
15
|
+
* devise.mailer.confirmations_instructions now should be devise.mailer.confirmations_instructions.subject
|
16
|
+
* devise.mailer.user.confirmations_instructions now should be devise.mailer.confirmations_instructions.user_subject
|
17
|
+
* Generators now use Rails 3 syntax (devise:install) instead of devise_install
|
18
|
+
|
19
|
+
== 1.1.rc
|
20
|
+
|
21
|
+
* enhancements
|
22
|
+
* Rails 3 compatibility
|
23
|
+
* All controllers and views are namespaced, for example: Devise::SessionsController and "devise/sessions"
|
24
|
+
* Devise.orm is deprecated. This reduces the required API to hook your ORM with devise
|
25
|
+
* Use metal for failure app
|
26
|
+
* HTML e-mails now have proper formatting
|
27
|
+
* Allow to give :skip and :controllers in routes
|
28
|
+
* Move trackable logic to the model
|
29
|
+
* E-mails now use any template available in the filesystem. Easy to create multipart e-mails
|
30
|
+
* E-mails asks headers_for in the model to set the proper headers
|
31
|
+
* Allow to specify haml in devise_views
|
32
|
+
* Compatibility with Datamapper and Mongoid
|
33
|
+
* Make config.devise available on config/application.rb
|
34
|
+
* TokenAuthenticatable now works with HTTP Basic Auth
|
35
|
+
* 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
|
36
|
+
* No need to append ?unauthenticated=true in URLs anymore since Flash was moved to a middleware in Rails 3
|
37
|
+
* :activatable is included by default in your models
|
38
|
+
|
39
|
+
* bug fix
|
40
|
+
* Fix a bug with STI
|
41
|
+
|
42
|
+
* deprecations
|
43
|
+
* Rails 3 compatible only
|
44
|
+
* Removed support for MongoMapper
|
45
|
+
* Scoped views are no longer "sessions/users/new". Now use "users/sessions/new"
|
46
|
+
* Devise.orm is deprecated, just require "devise/orm/YOUR_ORM" instead
|
47
|
+
* Devise.default_url_options is deprecated, just modify ApplicationController.default_url_options
|
48
|
+
* All messages under devise.sessions, except :signed_in and :signed_out, should be moved to devise.failure
|
49
|
+
* :as and :scope in routes is deprecated. Use :path and :singular instead
|
50
|
+
|
51
|
+
== 1.0.8
|
52
|
+
|
53
|
+
* enhancements
|
54
|
+
* Support for latest MongoMapper
|
55
|
+
* Added anybody_signed_in? helper (by github.com/SSDany)
|
56
|
+
|
57
|
+
* bug fix
|
58
|
+
* confirmation_required? is properly honored on active? calls. (by github.com/paulrosania)
|
59
|
+
|
60
|
+
== 1.0.7
|
21
61
|
|
22
62
|
* bug fix
|
23
|
-
*
|
63
|
+
* Ensure password confirmation is always required
|
24
64
|
|
25
65
|
* deprecations
|
26
|
-
*
|
27
|
-
*
|
28
|
-
* Devise.orm is deprecated, just require "devise/orm/YOUR_ORM" instead.
|
29
|
-
* Devise.default_url_options is deprecated, just modify ApplicationController.default_url_options.
|
30
|
-
* All messages under devise.sessions, except :signed_in and :signed_out, should be moved to devise.failure.
|
31
|
-
* :as and :scope in routes is deprecated. Use :path and :singular instead.
|
66
|
+
* authenticatable was deprecated and renamed to database_authenticatable
|
67
|
+
* confirmable is not included by default on generation
|
32
68
|
|
33
69
|
== 1.0.6
|
34
70
|
|
data/Gemfile
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
source "http://
|
1
|
+
source "http://rubygems.org"
|
2
2
|
|
3
3
|
# Need to install Rails from source
|
4
|
-
gem "rails", "3.0.0.
|
5
|
-
gem "warden", "0.10.
|
6
|
-
gem "sqlite3-ruby"
|
7
|
-
gem "webrat", "0.7"
|
4
|
+
gem "rails", "3.0.0.beta4"
|
5
|
+
gem "warden", "0.10.7"
|
6
|
+
gem "sqlite3-ruby"
|
7
|
+
gem "webrat", "0.7.0"
|
8
8
|
gem "mocha", :require => false
|
9
9
|
gem "bcrypt-ruby", :require => "bcrypt"
|
10
10
|
|
@@ -13,15 +13,17 @@ if RUBY_VERSION < '1.9'
|
|
13
13
|
end
|
14
14
|
|
15
15
|
group :mongoid do
|
16
|
-
gem "mongo"
|
17
|
-
gem "mongo_ext", ">= 0.18.3", :require => false
|
16
|
+
gem "mongo"
|
18
17
|
gem "mongoid", :git => "git://github.com/durran/mongoid.git"
|
18
|
+
gem "bson_ext"
|
19
19
|
end
|
20
20
|
|
21
21
|
group :data_mapper do
|
22
|
-
gem
|
23
|
-
gem
|
24
|
-
gem
|
25
|
-
gem
|
26
|
-
gem
|
27
|
-
|
22
|
+
gem 'dm-core', '~> 1.0.0', :git => 'git://github.com/datamapper/dm-core'
|
23
|
+
gem 'dm-migrations', '~> 1.0.0', :git => 'git://github.com/datamapper/dm-migrations'
|
24
|
+
gem 'dm-sqlite-adapter', '~> 1.0.0', :git => 'git://github.com/datamapper/dm-sqlite-adapter'
|
25
|
+
gem 'dm-validations', '~> 1.0.0', :git => 'git://github.com/datamapper/dm-validations'
|
26
|
+
gem 'dm-serializer', '~> 1.0.0', :git => 'git://github.com/datamapper/dm-serializer'
|
27
|
+
gem 'dm-timestamps', '~> 1.0.0', :git => 'git://github.com/datamapper/dm-timestamps'
|
28
|
+
gem 'dm-rails', '~> 1.0.0', :git => 'git://github.com/datamapper/dm-rails'
|
29
|
+
end
|
data/README.rdoc
CHANGED
@@ -13,53 +13,74 @@ Right now it's composed of 11 modules:
|
|
13
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.
|
14
14
|
* Confirmable: sends emails with confirmation instructions and verifies whether an account is already confirmed during sign in.
|
15
15
|
* Recoverable: resets the user password and sends reset instructions.
|
16
|
-
* Registerable: handles signing up users through a registration process.
|
16
|
+
* Registerable: handles signing up users through a registration process, also allowing them to edit and destroy their account.
|
17
17
|
* Rememberable: manages generating and clearing a token for remembering the user from a saved cookie.
|
18
18
|
* Trackable: tracks sign in count, timestamps and IP address.
|
19
19
|
* Timeoutable: expires sessions that have no activity in a specified period of time.
|
20
20
|
* Validatable: provides validations of email and password. It's optional and can be customized, so you're able to define your own validations.
|
21
21
|
* Lockable: locks an account after a specified number of failed sign-in attempts. Can unlock via email or after a specified time period.
|
22
22
|
|
23
|
-
==
|
23
|
+
== Installation
|
24
24
|
|
25
|
-
|
26
|
-
* Example Rails 2.3 web app combining subdomains with Devise at http://github.com/fortuity/subdomain-authentication
|
25
|
+
=== Rails 3 beta 4
|
27
26
|
|
28
|
-
|
27
|
+
To use Devise with Rails 3 beta 4, please use it straight from the git repository, by adding it to your Gemfile:
|
29
28
|
|
30
|
-
|
29
|
+
gem "devise", :git => "git://github.com/plataformatec/devise.git"
|
31
30
|
|
32
|
-
|
31
|
+
Then follow the same steps as below.
|
32
|
+
|
33
|
+
=== Rails 3 beta 3
|
33
34
|
|
34
35
|
Devise master branch now supports Rails 3 and is NOT backward compatible. You can use the latest Rails 3 beta gem with Devise latest gem:
|
35
36
|
|
36
|
-
|
37
|
+
gem install devise --version=1.1.rc1
|
37
38
|
|
38
39
|
After you install Devise and add it to your Gemfile, you need to run the generator:
|
39
40
|
|
40
|
-
rails generate
|
41
|
+
rails generate devise:install
|
41
42
|
|
42
|
-
|
43
|
+
The generator will install an initializer which describes ALL Devise's configuration options and you MUST take a look at it. When you are done, you are ready to add Devise to any of your models using the generator:
|
43
44
|
|
44
|
-
|
45
|
+
rails generate devise MODEL
|
45
46
|
|
46
|
-
|
47
|
+
Replace MODEL by the class name you want to add devise, like User, Admin, etc. This will create a model (if one does not exist) and configure it with default Devise modules. The generator will also create a migration file (if your ORM support them) and configure your routes. Continue reading this file to understand exactly what the generator produces and how to use it.
|
47
48
|
|
48
|
-
|
49
|
-
|
50
|
-
== Rails 2.3
|
49
|
+
=== Rails 2.3
|
51
50
|
|
52
51
|
If you want to use the Rails 2.3.x version, you should do:
|
53
52
|
|
54
|
-
|
53
|
+
gem install devise --version=1.0.7
|
55
54
|
|
56
|
-
|
55
|
+
And please check the README at the v1.0 branch since this one is based on Rails 3:
|
57
56
|
|
58
57
|
http://github.com/plataformatec/devise/tree/v1.0
|
59
58
|
|
59
|
+
== Ecosystem
|
60
|
+
|
61
|
+
Devise ecosystem is growing solid day after day. If you just need a walkthrough about setting up Devise, this README will work great. But if you need more documentation and resources, please check both the wiki and rdoc:
|
62
|
+
|
63
|
+
* http://rdoc.info/projects/plataformatec/devise
|
64
|
+
* http://wiki.github.com/plataformatec/devise
|
65
|
+
|
66
|
+
Both links above are for Devise with Rails 3. If you need to use Devise with Rails 2.3, you can always run `gem server` from the command line after you install the gem to access the old documentation.
|
67
|
+
|
68
|
+
Another great way to learn Devise are Ryan Bates' screencasts:
|
69
|
+
|
70
|
+
* http://railscasts.com/episodes/209-introducing-devise
|
71
|
+
* http://railscasts.com/episodes/210-customizing-devise
|
72
|
+
|
73
|
+
And a few example applications:
|
74
|
+
|
75
|
+
* Rails 2.3 app using Devise at http://github.com/plataformatec/devise_example
|
76
|
+
* Rails 2.3 app using Devise with subdomains at http://github.com/fortuity/subdomain-authentication
|
77
|
+
* Rails 3.0 app with Mongoid at http://github.com/fortuity/rails3-mongoid-devise
|
78
|
+
|
79
|
+
Finally, Devise also has several extensions built by the community. Don't forget to check them at the end of this README. If you want to write an extension on your own, you should also check Warden (http://github.com/hassox/warden), a Rack Authentication Framework which Devise depends on.
|
80
|
+
|
60
81
|
== Basic Usage
|
61
82
|
|
62
|
-
This is a walkthrough with all steps you need to setup a devise resource, including model, migration, route files, and optional configuration.
|
83
|
+
This is a walkthrough with all steps you need to setup a devise resource, including model, migration, route files, and optional configuration.
|
63
84
|
|
64
85
|
Devise must be set up within the model (or models) you want to use. Devise routes must be created inside your config/routes.rb file.
|
65
86
|
|
@@ -88,13 +109,13 @@ Configure your routes after setting up your model. Open your config/routes.rb fi
|
|
88
109
|
|
89
110
|
This will use your User model to create a set of needed routes (you can see them by running `rake routes`).
|
90
111
|
|
91
|
-
Options for configuring your routes include :class_name (to set the class for that route), :path_prefix, :
|
112
|
+
Options for configuring your routes include :class_name (to set the class for that route), :path_prefix, :path and :path_names, where the last two have the same meaning as in common routes. The available :path_names are:
|
92
113
|
|
93
|
-
devise_for :users, :
|
114
|
+
devise_for :users, :path => "usuarios", :path_names => { :sign_in => 'login', :sign_out => 'logout', :password => 'secret', :confirmation => 'verification', :unlock => 'unblock', :registration => 'register', :sign_up => 'cmon_let_me_in' }
|
94
115
|
|
95
116
|
Be sure to check devise_for documentation for details.
|
96
117
|
|
97
|
-
|
118
|
+
This exactly what the devise generator produces for you: model, routes and migrations. Don't forget to run rake db:migrate and you are ready to go! But don't stop reading here, we still have a lot to tell you.
|
98
119
|
|
99
120
|
== Controller filters and helpers
|
100
121
|
|
@@ -133,13 +154,14 @@ Devise allows you to set up as many roles as you want. For example, you may have
|
|
133
154
|
t.database_authenticatable
|
134
155
|
t.lockable
|
135
156
|
t.trackable
|
157
|
+
t.timestamps
|
136
158
|
end
|
137
159
|
|
138
160
|
# Inside your Admin model
|
139
161
|
devise :database_authenticatable, :trackable, :timeoutable, :lockable
|
140
162
|
|
141
163
|
# Inside your routes
|
142
|
-
devise_for :
|
164
|
+
devise_for :admins
|
143
165
|
|
144
166
|
# Inside your protected controller
|
145
167
|
before_filter :authenticate_admin!
|
@@ -149,27 +171,13 @@ Devise allows you to set up as many roles as you want. For example, you may have
|
|
149
171
|
current_admin
|
150
172
|
admin_session
|
151
173
|
|
152
|
-
== Generators
|
153
|
-
|
154
|
-
Devise has generators to help you get started:
|
155
|
-
|
156
|
-
rails generate devise_install
|
157
|
-
|
158
|
-
This will generate an initializer, with a description of all configuration values.
|
159
|
-
|
160
|
-
You can also generate models:
|
161
|
-
|
162
|
-
rails generate devise Model
|
163
|
-
|
164
|
-
This will create a model named "Model" configured with default Devise modules and attr_accessible set for default fields. The generator will also create the migration and configure your routes for Devise.
|
165
|
-
|
166
174
|
== Model configuration
|
167
175
|
|
168
176
|
The devise method in your models also accepts some options to configure its modules. For example, you can choose which encryptor to use in database_authenticatable:
|
169
177
|
|
170
178
|
devise :database_authenticatable, :confirmable, :recoverable, :encryptor => :bcrypt
|
171
179
|
|
172
|
-
Besides :encryptor, you can define :pepper, :stretches, :confirm_within, :remember_for, :timeout_in, :unlock_in and other values. For details, see the initializer file that was created when you invoked the
|
180
|
+
Besides :encryptor, you can define :pepper, :stretches, :confirm_within, :remember_for, :timeout_in, :unlock_in and other values. For details, see the initializer file that was created when you invoked the "devise:install" generator described above.
|
173
181
|
|
174
182
|
== Configuring views
|
175
183
|
|
@@ -177,7 +185,7 @@ We built Devise to help you quickly develop an application that uses authenticat
|
|
177
185
|
|
178
186
|
Since Devise is an engine, all its views are packaged inside the gem. These views will help you get started, but after sometime you may want to change them. If this is the case, you just need to invoke the following generator, and it will copy all views to your application:
|
179
187
|
|
180
|
-
rails generate
|
188
|
+
rails generate devise:views
|
181
189
|
|
182
190
|
However, if you have more than one role in your application (such as "User" and "Admin"), you will notice that Devise uses the same views for all roles. Fortunately, Devise offers an easy way to customize views. All you need to do is set "config.scoped_views = true" inside "config/initializers/devise.rb".
|
183
191
|
|
@@ -257,6 +265,20 @@ Devise implements encryption strategies for Clearance, Authlogic and Restful-Aut
|
|
257
265
|
|
258
266
|
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.
|
259
267
|
|
268
|
+
== Extensions
|
269
|
+
|
270
|
+
Devise also has extensions created by the community:
|
271
|
+
|
272
|
+
* http://github.com/scambra/devise_invitable adds support to Devise for sending invitations by email.
|
273
|
+
|
274
|
+
* http://github.com/grimen/devise_facebook_connectable adds support for Facebook Connect authentication, and optionally fetching user info from Facebook in the same step.
|
275
|
+
|
276
|
+
* http://github.com/joshk/devise_imapable adds support for imap based authentication, excellent for internal apps when an LDAP server isn't available.
|
277
|
+
|
278
|
+
* http://github.com/cschiewek/devise_ldap_authenticatable adds support for LDAP authentication via simple bind.
|
279
|
+
|
280
|
+
Please consult their respective documentation for more information and requirements.
|
281
|
+
|
260
282
|
== TODO
|
261
283
|
|
262
284
|
Please refer to TODO file.
|
@@ -268,15 +290,9 @@ Please refer to TODO file.
|
|
268
290
|
|
269
291
|
== Contributors
|
270
292
|
|
271
|
-
We have a long list of valued contributors.
|
272
|
-
|
273
|
-
== Devise extensions
|
293
|
+
We have a long list of valued contributors. Check them all at:
|
274
294
|
|
275
|
-
|
276
|
-
|
277
|
-
* http://github.com/grimen/devise_facebook_connectable adds support for Facebook Connect authentication, and optionally fetching user info from Facebook in the same step.
|
278
|
-
|
279
|
-
* http://github.com/joshk/devise_imapable adds support for imap based authentication, excellent for internal apps when an LDAP server isn't available.
|
295
|
+
http://github.com/plataformatec/devise/contributors
|
280
296
|
|
281
297
|
== Bugs and Feedback
|
282
298
|
|
@@ -288,10 +304,6 @@ For support, send an e-mail to the mailing list.
|
|
288
304
|
|
289
305
|
http://groups.google.com/group/plataformatec-devise
|
290
306
|
|
291
|
-
See the wiki for additional documentation and support.
|
292
|
-
|
293
|
-
http://wiki.github.com/plataformatec/devise
|
294
|
-
|
295
307
|
== License
|
296
308
|
|
297
|
-
MIT License. Copyright
|
309
|
+
MIT License. Copyright 2010 Plataforma Tecnologia. http://blog.plataformatec.com.br
|
data/Rakefile
CHANGED
@@ -45,10 +45,11 @@ 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.10.
|
48
|
+
s.add_dependency("warden", "~> 0.10.7")
|
49
|
+
s.add_dependency("bcrypt-ruby", "~> 2.1.2")
|
49
50
|
end
|
50
51
|
|
51
52
|
Jeweler::GemcutterTasks.new
|
52
53
|
rescue LoadError
|
53
|
-
puts "Jeweler, or one of its dependencies, is not available. Install it with:
|
54
|
+
puts "Jeweler, or one of its dependencies, is not available. Install it with: gem install jeweler"
|
54
55
|
end
|
data/TODO
CHANGED
@@ -31,7 +31,7 @@ class Devise::RegistrationsController < ApplicationController
|
|
31
31
|
def update
|
32
32
|
if resource.update_with_password(params[resource_name])
|
33
33
|
set_flash_message :notice, :updated
|
34
|
-
redirect_to
|
34
|
+
redirect_to after_update_path_for(resource)
|
35
35
|
else
|
36
36
|
clean_up_passwords(resource)
|
37
37
|
render_with_scope :edit
|
@@ -1,6 +1,5 @@
|
|
1
1
|
class Devise::Mailer < ::ActionMailer::Base
|
2
2
|
include Devise::Controllers::ScopedViews
|
3
|
-
|
4
3
|
attr_reader :devise_mapping, :resource
|
5
4
|
|
6
5
|
def confirmation_instructions(record)
|
@@ -17,52 +16,53 @@ class Devise::Mailer < ::ActionMailer::Base
|
|
17
16
|
|
18
17
|
private
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
template_path = ["devise/mailer"]
|
27
|
-
template_path.unshift "#{@devise_mapping.plural}/mailer" if self.class.scoped_views?
|
19
|
+
# Configure default email options
|
20
|
+
def setup_mail(record, action)
|
21
|
+
@scope_name = Devise::Mapping.find_scope!(record)
|
22
|
+
@devise_mapping = Devise.mappings[@scope_name]
|
23
|
+
@resource = instance_variable_set("@#{@devise_mapping.name}", record)
|
28
24
|
|
29
|
-
|
30
|
-
|
31
|
-
:from => mailer_sender(@devise_mapping),
|
32
|
-
:to => record.email,
|
33
|
-
:template_path => template_path
|
34
|
-
}
|
25
|
+
template_path = ["devise/mailer"]
|
26
|
+
template_path.unshift "#{@devise_mapping.plural}/mailer" if self.class.scoped_views?
|
35
27
|
|
36
|
-
|
37
|
-
|
38
|
-
|
28
|
+
headers = {
|
29
|
+
:subject => translate(@devise_mapping, action),
|
30
|
+
:from => mailer_sender(@devise_mapping),
|
31
|
+
:to => record.email,
|
32
|
+
:template_path => template_path
|
33
|
+
}
|
39
34
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
@_message["template_path"] = nil
|
44
|
-
@_message
|
45
|
-
end
|
35
|
+
headers.merge!(record.headers_for(action)) if record.respond_to?(:headers_for)
|
36
|
+
mail(headers)
|
37
|
+
end
|
46
38
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
end
|
39
|
+
def mailer_sender(mapping)
|
40
|
+
if Devise.mailer_sender.is_a?(Proc)
|
41
|
+
Devise.mailer_sender.call(mapping.name)
|
42
|
+
else
|
43
|
+
Devise.mailer_sender
|
53
44
|
end
|
45
|
+
end
|
54
46
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
47
|
+
# Setup a subject doing an I18n lookup. At first, it attemps to set a subject
|
48
|
+
# based on the current mapping:
|
49
|
+
#
|
50
|
+
# en:
|
51
|
+
# devise:
|
52
|
+
# mailer:
|
53
|
+
# confirmation_instructions:
|
54
|
+
# user_subject: '...'
|
55
|
+
#
|
56
|
+
# If one does not exist, it fallbacks to ActionMailer default:
|
57
|
+
#
|
58
|
+
# en:
|
59
|
+
# devise:
|
60
|
+
# mailer:
|
61
|
+
# confirmation_instructions:
|
62
|
+
# subject: '...'
|
63
|
+
#
|
64
|
+
def translate(mapping, key)
|
65
|
+
I18n.t(:"#{mapping.name}_subject", :scope => [:devise, :mailer, key],
|
66
|
+
:default => [:subject, key.to_s.humanize])
|
67
|
+
end
|
68
68
|
end
|