devise 1.1.9 → 1.2.rc

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of devise might be problematic. Click here for more details.

Files changed (121) hide show
  1. data/CHANGELOG.rdoc +34 -26
  2. data/README.rdoc +134 -100
  3. data/app/controllers/devise/confirmations_controller.rb +1 -1
  4. data/app/controllers/devise/omniauth_callbacks_controller.rb +26 -0
  5. data/app/controllers/devise/passwords_controller.rb +1 -1
  6. data/app/controllers/devise/registrations_controller.rb +59 -6
  7. data/app/controllers/devise/sessions_controller.rb +3 -2
  8. data/app/controllers/devise/unlocks_controller.rb +1 -1
  9. data/app/helpers/devise_helper.rb +4 -2
  10. data/app/mailers/devise/mailer.rb +27 -10
  11. data/app/views/devise/confirmations/new.html.erb +1 -1
  12. data/app/views/devise/passwords/edit.html.erb +2 -2
  13. data/app/views/devise/passwords/new.html.erb +1 -1
  14. data/app/views/devise/registrations/edit.html.erb +1 -1
  15. data/app/views/devise/registrations/new.html.erb +1 -1
  16. data/app/views/devise/sessions/new.html.erb +1 -1
  17. data/app/views/devise/shared/_links.erb +6 -0
  18. data/app/views/devise/unlocks/new.html.erb +1 -1
  19. data/config/locales/en.yml +9 -2
  20. data/lib/devise.rb +116 -58
  21. data/lib/devise/controllers/helpers.rb +103 -107
  22. data/lib/devise/controllers/internal_helpers.rb +23 -7
  23. data/lib/devise/controllers/scoped_views.rb +4 -6
  24. data/lib/devise/controllers/url_helpers.rb +3 -5
  25. data/lib/devise/encryptors/base.rb +1 -1
  26. data/lib/devise/encryptors/restful_authentication_sha1.rb +4 -4
  27. data/lib/devise/failure_app.rb +29 -21
  28. data/lib/devise/hooks/forgetable.rb +2 -1
  29. data/lib/devise/hooks/rememberable.rb +11 -9
  30. data/lib/devise/mapping.rb +12 -5
  31. data/lib/devise/models.rb +0 -14
  32. data/lib/devise/models/authenticatable.rb +40 -30
  33. data/lib/devise/models/confirmable.rb +11 -15
  34. data/lib/devise/models/database_authenticatable.rb +23 -35
  35. data/lib/devise/models/encryptable.rb +65 -0
  36. data/lib/devise/models/lockable.rb +8 -7
  37. data/lib/devise/models/omniauthable.rb +23 -0
  38. data/lib/devise/models/recoverable.rb +5 -3
  39. data/lib/devise/models/registerable.rb +13 -0
  40. data/lib/devise/models/rememberable.rb +38 -30
  41. data/lib/devise/models/timeoutable.rb +20 -3
  42. data/lib/devise/models/token_authenticatable.rb +19 -7
  43. data/lib/devise/models/validatable.rb +16 -4
  44. data/lib/devise/modules.rb +15 -8
  45. data/lib/devise/omniauth.rb +47 -0
  46. data/lib/devise/omniauth/config.rb +30 -0
  47. data/lib/devise/omniauth/test_helpers.rb +57 -0
  48. data/lib/devise/omniauth/url_helpers.rb +29 -0
  49. data/lib/devise/orm/active_record.rb +2 -0
  50. data/lib/devise/orm/mongoid.rb +4 -2
  51. data/lib/devise/rails.rb +26 -46
  52. data/lib/devise/rails/routes.rb +64 -20
  53. data/lib/devise/rails/warden_compat.rb +18 -20
  54. data/lib/devise/schema.rb +13 -14
  55. data/lib/devise/strategies/authenticatable.rb +33 -7
  56. data/lib/devise/strategies/database_authenticatable.rb +1 -1
  57. data/lib/devise/strategies/rememberable.rb +1 -1
  58. data/lib/devise/strategies/token_authenticatable.rb +6 -2
  59. data/lib/devise/test_helpers.rb +11 -1
  60. data/lib/devise/version.rb +1 -1
  61. data/lib/generators/active_record/templates/migration.rb +1 -0
  62. data/lib/generators/devise/orm_helpers.rb +3 -2
  63. data/lib/generators/templates/devise.rb +70 -39
  64. data/test/controllers/helpers_test.rb +43 -67
  65. data/test/controllers/internal_helpers_test.rb +29 -8
  66. data/test/controllers/url_helpers_test.rb +2 -1
  67. data/test/failure_app_test.rb +56 -21
  68. data/test/generators/generators_test_helper.rb +4 -0
  69. data/test/generators/install_generator_test.rb +14 -0
  70. data/test/generators/views_generator_test.rb +37 -0
  71. data/test/integration/authenticatable_test.rb +147 -62
  72. data/test/integration/database_authenticatable_test.rb +22 -0
  73. data/test/integration/http_authenticatable_test.rb +12 -2
  74. data/test/integration/omniauthable_test.rb +107 -0
  75. data/test/integration/recoverable_test.rb +39 -20
  76. data/test/integration/registerable_test.rb +30 -4
  77. data/test/integration/rememberable_test.rb +57 -34
  78. data/test/integration/timeoutable_test.rb +10 -1
  79. data/test/integration/token_authenticatable_test.rb +12 -17
  80. data/test/mailers/confirmation_instructions_test.rb +4 -0
  81. data/test/mailers/reset_password_instructions_test.rb +4 -0
  82. data/test/mailers/unlock_instructions_test.rb +4 -0
  83. data/test/mapping_test.rb +37 -3
  84. data/test/models/confirmable_test.rb +3 -3
  85. data/test/models/database_authenticatable_test.rb +14 -71
  86. data/test/models/encryptable_test.rb +65 -0
  87. data/test/models/lockable_test.rb +17 -1
  88. data/test/models/recoverable_test.rb +17 -0
  89. data/test/models/rememberable_test.rb +186 -125
  90. data/test/models/token_authenticatable_test.rb +1 -13
  91. data/test/models_test.rb +5 -5
  92. data/test/omniauth/url_helpers_test.rb +47 -0
  93. data/test/rails_app/app/active_record/admin.rb +4 -1
  94. data/test/rails_app/app/active_record/user.rb +5 -4
  95. data/test/rails_app/app/controllers/{sessions_controller.rb → admins/sessions_controller.rb} +1 -1
  96. data/test/rails_app/app/controllers/home_controller.rb +9 -0
  97. data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +7 -0
  98. data/test/rails_app/app/mongoid/admin.rb +4 -1
  99. data/test/rails_app/app/mongoid/shim.rb +16 -3
  100. data/test/rails_app/app/mongoid/user.rb +5 -5
  101. data/test/rails_app/config/initializers/devise.rb +52 -28
  102. data/test/rails_app/config/routes.rb +14 -6
  103. data/test/rails_app/db/migrate/20100401102949_create_tables.rb +21 -17
  104. data/test/rails_app/db/schema.rb +17 -51
  105. data/test/rails_app/lib/shared_admin.rb +9 -0
  106. data/test/rails_app/lib/shared_user.rb +23 -0
  107. data/test/routes_test.rb +42 -9
  108. data/test/support/integration.rb +3 -3
  109. data/test/support/webrat/integrations/rails.rb +7 -0
  110. data/test/test_helper.rb +2 -0
  111. data/test/test_helpers_test.rb +29 -0
  112. metadata +60 -30
  113. data/Gemfile +0 -27
  114. data/Gemfile.lock +0 -115
  115. data/Rakefile +0 -55
  116. data/TODO +0 -3
  117. data/lib/devise/encryptors/bcrypt.rb +0 -19
  118. data/lib/generators/devise_install_generator.rb +0 -4
  119. data/lib/generators/devise_views_generator.rb +0 -4
  120. data/test/indifferent_hash.rb +0 -33
  121. data/test/support/test_silencer.rb +0 -5
@@ -1,32 +1,40 @@
1
- == 1.1.9
1
+ == 1.2.rc
2
2
 
3
- * bugfix
4
- * double check if warden has not halted
5
-
6
- == 1.1.8
7
-
8
- * bugfix
9
- * Ensure you can't inject Mongoid queries using token authenticatable
10
-
11
- == 1.1.7
12
-
13
- * bugfix
14
- * Fix a backward incompatible change with versions prior to Rails 3.0.4
15
-
16
- == 1.1.6
17
-
18
- * bugfix
19
- * Use a more secure e-mail regexp
20
- * Implement Rails 3.0.4 handle unverified request
21
- * Use secure_compare to compare passwords
22
-
23
- == 1.1.5
3
+ * deprecations
4
+ * cookie_domain is deprecated in favor of cookie_options
5
+ * after_update_path_for can no longer be defined in ApplicationController
6
+
7
+ * enhancements
8
+ * Added OmniAuth support
9
+ * Added ORM adapter to abstract ORM iteraction
10
+ * sign_out_via is available in the router to configure the method used for sign out (by github.com/martinrehfeld)
11
+ * Improved Ajax requests handling in failure app (by github.com/spastorino)
12
+ * Added request_keys to easily use request specific values (like subdomain) in authentication
13
+ * Increased the size of friendly_token to 60 characters (reduces the chances of a successful brute attack)
14
+ * Ensure the friendly token does not include "_" or "-" since some e-mails may not autolink it properly (by github.com/rymai)
15
+ * Extracted encryptors into :encryptable for better bcrypt support
16
+ * :rememberable is now able to use salt as token if no remember_token is provided
17
+ * Store the salt in session and expire the session if the user changes his password
18
+ * Allow :stateless_token to be set to true avoiding users to be stored in session through token authentication
19
+ * cookie_options uses session_options values by default
20
+ * Sign up now check if the user is active or not and redirect him accordingly setting the inactive_signed_up message
21
+ * Use ActiveModel#to_key instead of #id
22
+ * sign_out_all_scopes now destroys the whole session
23
+ * Added case_insensitive_keys that automatically downcases the given keys, by default downcases only e-mail (by github.com/adahl)
24
+
25
+ * default behavior changes
26
+ * sign_out_all_scopes defaults to true as security measure
27
+ * http authenticatable is disabled by default
28
+ * Devise does not intercept 401 returned from applications
24
29
 
25
30
  * bugfix
26
- * Ensure to convert keys on indifferent hash
27
-
28
- * defaults
29
- * Set config.http_authenticatable to false to avoid confusion
31
+ * after_sign_in_path_for always receives a resource
32
+ * Do not execute Warden::Callbacks on Devise::TestHelpers (by github.com/sgronblo)
33
+ * Password recovery and account unlocking takes into account authentication keys (by github.com/RStankov)
34
+ * FailureApp now properly handles nil request.format
35
+ * Fix a bug causing FailureApp to return with HTTP Auth Headers for IE7
36
+ * Ensure namespaces has proper scoped views
37
+ * Ensure Devise does not set empty flash messages (by github.com/sxross)
30
38
 
31
39
  == 1.1.4
32
40
 
@@ -7,10 +7,11 @@ 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 11 modules:
10
+ It's composed of 12 modules:
11
11
 
12
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.
13
+ * Token Authenticatable: signs in a 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
+ * Omniauthable: adds Omniauth (github.com/intridea/omniauth) support;
14
15
  * Confirmable: sends emails with confirmation instructions and verifies whether an account is already confirmed during sign in.
15
16
  * Recoverable: resets the user password and sends reset instructions.
16
17
  * Registerable: handles signing up users through a registration process, also allowing them to edit and destroy their account.
@@ -19,58 +20,75 @@ Right now it's composed of 11 modules:
19
20
  * Timeoutable: expires sessions that have no activity in a specified period of time.
20
21
  * Validatable: provides validations of email and password. It's optional and can be customized, so you're able to define your own validations.
21
22
  * Lockable: locks an account after a specified number of failed sign-in attempts. Can unlock via email or after a specified time period.
23
+ * Encryptable: allows support of other authentication mechanisms besides Bcrypt (the default).
22
24
 
23
- == Installation
25
+ == Information
24
26
 
25
- Devise 1.1 supports Rails 3 and is NOT backward compatible. You can use the latest Rails 3 beta gem with Devise latest gem:
27
+ === The Devise Wiki
26
28
 
27
- gem install devise --version=1.1.7
29
+ The Devise Wiki has lots of additional information about Devise including many "how-to" articles and answers to the most frequently asked questions. Please browse the Wiki after finishing this README:
28
30
 
29
- If you want to use Rails master (from git repository) you need to use Devise from git repository and vice-versa.
31
+ http://wiki.github.com/plataformatec/devise
30
32
 
31
- After you install Devise and add it to your Gemfile, you need to run the generator:
33
+ === Bug reports
32
34
 
33
- rails generate devise:install
35
+ If you discover a problem with Devise, we would like to know about it. However, we ask that you please review these guidelines before submitting a bug report:
34
36
 
35
- 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:
37
+ http://github.com/plataformatec/devise/wiki/Bug-reports
36
38
 
37
- rails generate devise MODEL
39
+ If you found a security bug, do *NOT* use the GitHub Issue tracker. Send private GitHub message or email to the maintainers listed in the bottom of the README.
38
40
 
39
- 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.
41
+ === Google Group
42
+
43
+ If you have any questions, comments, or concerns please use the Google Group instead of the GitHub Issues tracker:
44
+
45
+ http://groups.google.com/group/plataformatec-devise
46
+
47
+ === RDocs
40
48
 
41
- == Rails 2.3
49
+ You can view the Devise documentation in RDoc format here:
42
50
 
43
- If you want to use the Rails 2.3.x version, you should do:
51
+ http://rubydoc.info/github/plataformatec/devise/master/frames
44
52
 
45
- gem install devise --version=1.0.10
53
+ 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.
46
54
 
47
- And please check the README at the v1.0 branch since this one is based on Rails 3:
55
+ === Example Applications
48
56
 
49
- http://github.com/plataformatec/devise/tree/v1.0
57
+ There are a few example applications available on GitHub that demonstrate various features of Devise with different versions of Rails. You can view them here:
50
58
 
51
- == Ecosystem
59
+ http://github.com/plataformatec/devise/wiki/Example-Applications
52
60
 
53
- 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:
61
+ === Extensions
54
62
 
55
- * http://rdoc.info/projects/plataformatec/devise
56
- * http://wiki.github.com/plataformatec/devise
63
+ Our community has created a number of extensions that add functionality above and beyond what is included with Devise. You can view a list of available extensions and add your own here:
57
64
 
58
- 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.
65
+ http://github.com/plataformatec/devise/wiki/Extensions
59
66
 
60
- Another great way to learn Devise are Ryan Bates' screencasts:
67
+ === Contributing
61
68
 
62
- * http://railscasts.com/episodes/209-introducing-devise
63
- * http://railscasts.com/episodes/210-customizing-devise
69
+ We hope that you will consider contributing to Devise. Please read this short overview for some information about how to get started:
64
70
 
65
- And a few example applications:
71
+ http://github.com/plataformatec/devise/wiki/Contributing
66
72
 
67
- * Rails 2.3 app using Devise at http://github.com/plataformatec/devise_example
68
- * Rails 2.3 app using Devise with subdomains at http://github.com/fortuity/subdomain-authentication
69
- * Rails 3.0 app with Mongoid at http://github.com/fortuity/rails3-mongoid-devise
73
+ == Installation
74
+
75
+ You can use the latest Rails 3 gem with the latest Devise gem:
76
+
77
+ gem install devise
78
+
79
+ After you install Devise and add it to your Gemfile, you need to run the generator:
70
80
 
71
- 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.
81
+ rails generate devise:install
72
82
 
73
- == Basic Usage
83
+ 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:
84
+
85
+ rails generate devise MODEL
86
+
87
+ 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.
88
+
89
+ Support for Rails 2.3.x can be found by installing Devise 1.0.x from the v1.0 branch.
90
+
91
+ == Getting started
74
92
 
75
93
  This is a walkthrough with all steps you need to setup a devise resource, including model, migration, route files, and optional configuration.
76
94
 
@@ -99,17 +117,11 @@ Configure your routes after setting up your model. Open your config/routes.rb fi
99
117
 
100
118
  devise_for :users
101
119
 
102
- This will use your User model to create a set of needed routes (you can see them by running `rake routes`).
103
-
104
- 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:
105
-
106
- 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' }
107
-
108
- Be sure to check devise_for documentation for details.
120
+ This will use your User model to create a set of needed routes (you can see them by running `rake routes`). If you invoked the devise generator, you noticed that this is exactly what the generator produces for us: model, routes and migrations.
109
121
 
110
- 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.
122
+ 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.
111
123
 
112
- == Controller filters and helpers
124
+ === Controller filters and helpers
113
125
 
114
126
  Devise will create some helpers to use inside your controllers and views. To set up a controller with user authentication, just add this before_filter:
115
127
 
@@ -137,7 +149,25 @@ Finally, you need to set up default url options for the mailer in each environme
137
149
 
138
150
  config.action_mailer.default_url_options = { :host => 'localhost:3000' }
139
151
 
140
- == Tidying up
152
+ Notice that if your devise model is not called "user" but "member", then the helpers you should use are:
153
+
154
+ before_filter :authenticate_member!
155
+
156
+ member_signed_in?
157
+
158
+ current_member
159
+
160
+ member_session
161
+
162
+ === Configuring Models
163
+
164
+ 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:
165
+
166
+ devise :database_authenticatable, :confirmable, :recoverable, :stretches => 20
167
+
168
+ Besides :stretches, you can define :pepper, :encryptor, :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.
169
+
170
+ === Configuring multiple models
141
171
 
142
172
  Devise allows you to set up as many roles as you want. For example, you may have a User model and also want an Admin model with just authentication, trackable, lockable and timeoutable features and no confirmation or password-recovery features. Just follow these steps:
143
173
 
@@ -163,15 +193,7 @@ Devise allows you to set up as many roles as you want. For example, you may have
163
193
  current_admin
164
194
  admin_session
165
195
 
166
- == Model configuration
167
-
168
- 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
-
170
- devise :database_authenticatable, :confirmable, :recoverable, :encryptor => :bcrypt
171
-
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 "devise:install" generator described above.
173
-
174
- == Configuring views
196
+ === Configuring views
175
197
 
176
198
  We built Devise to help you quickly develop an application that uses authentication. However, we don't want to be in your way when you need to customize it.
177
199
 
@@ -179,11 +201,15 @@ Since Devise is an engine, all its views are packaged inside the gem. These view
179
201
 
180
202
  rails generate devise:views
181
203
 
182
- 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".
204
+ If you are using HAML, you will need hpricot installed to convert Devise views to HAML.
205
+
206
+ 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
207
 
184
- After doing so, you will be able to have views based on the role like "users/sessions/new" and "admins/sessions/new". If no view is found within the scope, Devise will use the default view at "devise/sessions/new".
208
+ After doing so, you will be able to have views based on the role like "users/sessions/new" and "admins/sessions/new". If no view is found within the scope, Devise will use the default view at "devise/sessions/new". You can also use the generator to generate scoped views:
185
209
 
186
- == Configuring controllers
210
+ rails generate devise:views users
211
+
212
+ === Configuring controllers
187
213
 
188
214
  If the customization at the views level is not enough, you can customize each controller by following these steps:
189
215
 
@@ -194,13 +220,35 @@ If the customization at the views level is not enough, you can customize each co
194
220
 
195
221
  2) Tell the router to use this controller:
196
222
 
197
- devise_for :admins, :controllers => { :sessions => "admin/sessions" }
223
+ devise_for :admins, :controllers => { :sessions => "admins/sessions" }
198
224
 
199
225
  3) And since we changed the controller, it won't use the "devise/sessions" views, so remember to copy "devise/sessions" to "admin/sessions".
200
226
 
201
227
  Remember that Devise uses flash messages to let users know if sign in was successful or failed. Devise expects your application to call "flash[:notice]" and "flash[:alert]" as appropriate.
202
228
 
203
- == I18n
229
+ === Configuring routes
230
+
231
+ Devise also ships with default routes. If you need to customize them, you should probably be able to do it through the devise_for method. It accepts several options like :class_name, :path_prefix and so on, including the possibility to change path names for I18n:
232
+
233
+ 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' }
234
+
235
+ Be sure to check devise_for documentation for details.
236
+
237
+ If you have the need for more deep customization, for instance to also allow "/sign_in" besides "/users/sign_in", all you need to do is to create your routes normally and wrap them in a +devise_scope+ block in the router:
238
+
239
+ devise_scope :user do
240
+ get "sign_in", :to => "devise/sessions#new"
241
+ end
242
+
243
+ This way you tell devise to use the scope :user when "/sign_in" is accessed. Notice +devise_scope+ is also aliased as +as+ and you can also give a block to +devise_for+, resulting in the same behavior:
244
+
245
+ devise_for :users do
246
+ get "sign_in", :to => "devise/sessions#new"
247
+ end
248
+
249
+ Feel free to choose the one you prefer!
250
+
251
+ === I18n
204
252
 
205
253
  Devise uses flash messages with I18n with the flash keys :success and :failure. To customize your app, you can set up your locale file:
206
254
 
@@ -219,19 +267,22 @@ You can also create distinct messages based on the resource you've configured us
219
267
  admin:
220
268
  signed_in: 'Hello admin!'
221
269
 
222
- The Devise mailer uses the same pattern to create subject messages:
270
+ The Devise mailer uses a similar pattern to create subject messages:
223
271
 
224
272
  en:
225
273
  devise:
226
274
  mailer:
227
- confirmation_instructions: 'Hello everybody!'
228
- user:
229
- confirmation_instructions: 'Hello User! Please confirm your email'
230
- reset_password_instructions: 'Reset instructions'
275
+ confirmation_instructions:
276
+ subject: 'Hello everybody!'
277
+ user_subject: 'Hello User! Please confirm your email'
278
+ reset_password_instructions:
279
+ subject: 'Reset instructions'
280
+
281
+ Take a look at our locale file to check all available messages. You may also be interested in one of the many translations that are available on our wiki:
231
282
 
232
- Take a look at our locale file to check all available messages.
283
+ http://github.com/plataformatec/devise/wiki/I18n
233
284
 
234
- == Test helpers
285
+ === Test helpers
235
286
 
236
287
  Devise includes some tests helpers for functional specs. To use them, you just need to include Devise::TestHelpers in your test class and use the sign_in and sign_out method. Such methods have the same signature as in controllers:
237
288
 
@@ -241,70 +292,53 @@ Devise includes some tests helpers for functional specs. To use them, you just n
241
292
  sign_out :user # sign_out(scope)
242
293
  sign_out @user # sign_out(resource)
243
294
 
244
- You can include the Devise Test Helpers in all of your tests by adding the following to the bottom of your test/test_helper.rb or spec/spec_helper.rb file:
295
+ You can include the Devise Test Helpers in all of your tests by adding the following to the bottom of your test/test_helper.rb file:
245
296
 
246
297
  class ActionController::TestCase
247
298
  include Devise::TestHelpers
248
299
  end
249
300
 
250
- Do not use such helpers for integration tests such as Cucumber or Webrat. Instead, fill in the form or explicitly set the user in session. For more tips, check the wiki (http://wiki.github.com/plataformatec/devise).
251
-
252
- == Migrating from other solutions
253
-
254
- Devise implements encryption strategies for Clearance, Authlogic and Restful-Authentication. To make use of these strategies, set the desired encryptor in the encryptor initializer config option. You might also need to rename your encrypted password and salt columns to match Devise's fields (encrypted_password and password_salt).
301
+ If you're using RSpec and want the helpers automatically included within all +describe+ blocks, add a file called spec/support/devise.rb with the following contents:
255
302
 
256
- == Other ORMs
257
-
258
- 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
-
260
- == Extensions
261
-
262
- Devise also has extensions created by the community:
263
-
264
- * http://github.com/scambra/devise_invitable adds support to Devise for sending invitations by email.
303
+ RSpec.configure do |config|
304
+ config.include Devise::TestHelpers, :type => :controller
305
+ end
265
306
 
266
- * http://github.com/grimen/devise_facebook_connectable adds support for Facebook Connect authentication, and optionally fetching user info from Facebook in the same step.
307
+ Do not use such helpers for integration tests such as Cucumber or Webrat. Instead, fill in the form or explicitly set the user in session. For more tips, check the wiki (http://wiki.github.com/plataformatec/devise).
267
308
 
268
- * http://github.com/joshk/devise_imapable adds support for imap based authentication, excellent for internal apps when an LDAP server isn't available.
309
+ === OAuth2
269
310
 
270
- * http://github.com/cschiewek/devise_ldap_authenticatable adds support for LDAP authentication via simple bind.
311
+ Devise comes with OAuth support out of the box if you're using Devise from the git repository (for now). You can read more about OAuth2 support in the wiki:
271
312
 
272
- Please consult their respective documentation for more information and requirements.
313
+ * http://github.com/plataformatec/devise/wiki/OAuth2:-Overview
314
+ * http://github.com/plataformatec/devise/wiki/OAuth2:-Testing
273
315
 
274
- == TODO
316
+ === Other ORMs
275
317
 
276
- Please refer to TODO file.
318
+ Devise supports ActiveRecord (default) and Mongoid. To choose other ORM, you just need to require it in the initializer file.
277
319
 
278
- == Security
320
+ === Migrating from other solutions
279
321
 
280
- Needless to say, security is extremely important to Devise. If you find yourself in a possible security issue with Devise, please go through the following steps, trying to reproduce the bug:
322
+ Devise implements encryption strategies for Clearance, Authlogic and Restful-Authentication. To make use of these strategies, you need set the desired encryptor in the encryptor initializer config option and add :encryptable to your model. You might also need to rename your encrypted password and salt columns to match Devise's fields (encrypted_password and password_salt).
281
323
 
282
- 1) Look at the source code a bit to find out whether your assumptions are correct;
283
- 2) If possible, provide a way to reproduce the bug: a small app on Github or a step-by-step to reproduce;
284
- 3) E-mail us or send a Github private message instead of using the normal issues;
324
+ == Additional information
285
325
 
286
- Being able to reproduce the bug is the first step to fix it. Thanks for your understanding.
326
+ === Warden
287
327
 
288
- == Maintainers
328
+ Devise is based on Warden, which is a general Rack authentication framework created by Daniel Neighman. We encourage you to read more about Warden here:
289
329
 
290
- * José Valim (http://github.com/josevalim)
291
- * Carlos Antônio da Silva (http://github.com/carlosantoniodasilva)
330
+ http://github.com/hassox/warden
292
331
 
293
- == Contributors
332
+ === Contributors
294
333
 
295
334
  We have a long list of valued contributors. Check them all at:
296
335
 
297
336
  http://github.com/plataformatec/devise/contributors
298
337
 
299
- == Bugs and Feedback
300
-
301
- If you discover any bugs, please create an issue on GitHub.
302
-
303
- http://github.com/plataformatec/devise/issues
338
+ === Maintainers
304
339
 
305
- For support, send an e-mail to the mailing list.
306
-
307
- http://groups.google.com/group/plataformatec-devise
340
+ * José Valim (http://github.com/josevalim)
341
+ * Carlos Antônio da Silva (http://github.com/carlosantoniodasilva)
308
342
 
309
343
  == License
310
344
 
@@ -3,7 +3,7 @@ class Devise::ConfirmationsController < ApplicationController
3
3
 
4
4
  # GET /resource/confirmation/new
5
5
  def new
6
- build_resource
6
+ build_resource({})
7
7
  render_with_scope :new
8
8
  end
9
9
 
@@ -0,0 +1,26 @@
1
+ class Devise::OmniauthCallbacksController < ApplicationController
2
+ include Devise::Controllers::InternalHelpers
3
+
4
+ def failure
5
+ set_flash_message :alert, :failure, :kind => failed_strategy.name.to_s.humanize, :reason => failure_message
6
+ redirect_to after_omniauth_failure_path_for(resource_name)
7
+ end
8
+
9
+ protected
10
+
11
+ def failed_strategy
12
+ env["omniauth.failed_strategy"]
13
+ end
14
+
15
+ def failure_message
16
+ exception = env["omniauth.error"]
17
+ error = exception.error_reason if exception.respond_to?(:error_reason)
18
+ error ||= exception.error if exception.respond_to?(:error)
19
+ error ||= env["omniauth.failure_key"]
20
+ error.to_s.humanize if error
21
+ end
22
+
23
+ def after_omniauth_failure_path_for(scope)
24
+ new_session_path(scope)
25
+ end
26
+ end