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.
- data/CHANGELOG.rdoc +34 -26
- data/README.rdoc +134 -100
- data/app/controllers/devise/confirmations_controller.rb +1 -1
- data/app/controllers/devise/omniauth_callbacks_controller.rb +26 -0
- data/app/controllers/devise/passwords_controller.rb +1 -1
- data/app/controllers/devise/registrations_controller.rb +59 -6
- data/app/controllers/devise/sessions_controller.rb +3 -2
- data/app/controllers/devise/unlocks_controller.rb +1 -1
- data/app/helpers/devise_helper.rb +4 -2
- data/app/mailers/devise/mailer.rb +27 -10
- data/app/views/devise/confirmations/new.html.erb +1 -1
- data/app/views/devise/passwords/edit.html.erb +2 -2
- data/app/views/devise/passwords/new.html.erb +1 -1
- data/app/views/devise/registrations/edit.html.erb +1 -1
- data/app/views/devise/registrations/new.html.erb +1 -1
- data/app/views/devise/sessions/new.html.erb +1 -1
- data/app/views/devise/shared/_links.erb +6 -0
- data/app/views/devise/unlocks/new.html.erb +1 -1
- data/config/locales/en.yml +9 -2
- data/lib/devise.rb +116 -58
- data/lib/devise/controllers/helpers.rb +103 -107
- data/lib/devise/controllers/internal_helpers.rb +23 -7
- data/lib/devise/controllers/scoped_views.rb +4 -6
- data/lib/devise/controllers/url_helpers.rb +3 -5
- data/lib/devise/encryptors/base.rb +1 -1
- data/lib/devise/encryptors/restful_authentication_sha1.rb +4 -4
- data/lib/devise/failure_app.rb +29 -21
- data/lib/devise/hooks/forgetable.rb +2 -1
- data/lib/devise/hooks/rememberable.rb +11 -9
- data/lib/devise/mapping.rb +12 -5
- data/lib/devise/models.rb +0 -14
- data/lib/devise/models/authenticatable.rb +40 -30
- data/lib/devise/models/confirmable.rb +11 -15
- data/lib/devise/models/database_authenticatable.rb +23 -35
- data/lib/devise/models/encryptable.rb +65 -0
- data/lib/devise/models/lockable.rb +8 -7
- data/lib/devise/models/omniauthable.rb +23 -0
- data/lib/devise/models/recoverable.rb +5 -3
- data/lib/devise/models/registerable.rb +13 -0
- data/lib/devise/models/rememberable.rb +38 -30
- data/lib/devise/models/timeoutable.rb +20 -3
- data/lib/devise/models/token_authenticatable.rb +19 -7
- data/lib/devise/models/validatable.rb +16 -4
- data/lib/devise/modules.rb +15 -8
- data/lib/devise/omniauth.rb +47 -0
- data/lib/devise/omniauth/config.rb +30 -0
- data/lib/devise/omniauth/test_helpers.rb +57 -0
- data/lib/devise/omniauth/url_helpers.rb +29 -0
- data/lib/devise/orm/active_record.rb +2 -0
- data/lib/devise/orm/mongoid.rb +4 -2
- data/lib/devise/rails.rb +26 -46
- data/lib/devise/rails/routes.rb +64 -20
- data/lib/devise/rails/warden_compat.rb +18 -20
- data/lib/devise/schema.rb +13 -14
- data/lib/devise/strategies/authenticatable.rb +33 -7
- data/lib/devise/strategies/database_authenticatable.rb +1 -1
- data/lib/devise/strategies/rememberable.rb +1 -1
- data/lib/devise/strategies/token_authenticatable.rb +6 -2
- data/lib/devise/test_helpers.rb +11 -1
- data/lib/devise/version.rb +1 -1
- data/lib/generators/active_record/templates/migration.rb +1 -0
- data/lib/generators/devise/orm_helpers.rb +3 -2
- data/lib/generators/templates/devise.rb +70 -39
- data/test/controllers/helpers_test.rb +43 -67
- data/test/controllers/internal_helpers_test.rb +29 -8
- data/test/controllers/url_helpers_test.rb +2 -1
- data/test/failure_app_test.rb +56 -21
- data/test/generators/generators_test_helper.rb +4 -0
- data/test/generators/install_generator_test.rb +14 -0
- data/test/generators/views_generator_test.rb +37 -0
- data/test/integration/authenticatable_test.rb +147 -62
- data/test/integration/database_authenticatable_test.rb +22 -0
- data/test/integration/http_authenticatable_test.rb +12 -2
- data/test/integration/omniauthable_test.rb +107 -0
- data/test/integration/recoverable_test.rb +39 -20
- data/test/integration/registerable_test.rb +30 -4
- data/test/integration/rememberable_test.rb +57 -34
- data/test/integration/timeoutable_test.rb +10 -1
- data/test/integration/token_authenticatable_test.rb +12 -17
- data/test/mailers/confirmation_instructions_test.rb +4 -0
- data/test/mailers/reset_password_instructions_test.rb +4 -0
- data/test/mailers/unlock_instructions_test.rb +4 -0
- data/test/mapping_test.rb +37 -3
- data/test/models/confirmable_test.rb +3 -3
- data/test/models/database_authenticatable_test.rb +14 -71
- data/test/models/encryptable_test.rb +65 -0
- data/test/models/lockable_test.rb +17 -1
- data/test/models/recoverable_test.rb +17 -0
- data/test/models/rememberable_test.rb +186 -125
- data/test/models/token_authenticatable_test.rb +1 -13
- data/test/models_test.rb +5 -5
- data/test/omniauth/url_helpers_test.rb +47 -0
- data/test/rails_app/app/active_record/admin.rb +4 -1
- data/test/rails_app/app/active_record/user.rb +5 -4
- data/test/rails_app/app/controllers/{sessions_controller.rb → admins/sessions_controller.rb} +1 -1
- data/test/rails_app/app/controllers/home_controller.rb +9 -0
- data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +7 -0
- data/test/rails_app/app/mongoid/admin.rb +4 -1
- data/test/rails_app/app/mongoid/shim.rb +16 -3
- data/test/rails_app/app/mongoid/user.rb +5 -5
- data/test/rails_app/config/initializers/devise.rb +52 -28
- data/test/rails_app/config/routes.rb +14 -6
- data/test/rails_app/db/migrate/20100401102949_create_tables.rb +21 -17
- data/test/rails_app/db/schema.rb +17 -51
- data/test/rails_app/lib/shared_admin.rb +9 -0
- data/test/rails_app/lib/shared_user.rb +23 -0
- data/test/routes_test.rb +42 -9
- data/test/support/integration.rb +3 -3
- data/test/support/webrat/integrations/rails.rb +7 -0
- data/test/test_helper.rb +2 -0
- data/test/test_helpers_test.rb +29 -0
- metadata +60 -30
- data/Gemfile +0 -27
- data/Gemfile.lock +0 -115
- data/Rakefile +0 -55
- data/TODO +0 -3
- data/lib/devise/encryptors/bcrypt.rb +0 -19
- data/lib/generators/devise_install_generator.rb +0 -4
- data/lib/generators/devise_views_generator.rb +0 -4
- data/test/indifferent_hash.rb +0 -33
- data/test/support/test_silencer.rb +0 -5
data/CHANGELOG.rdoc
CHANGED
@@ -1,32 +1,40 @@
|
|
1
|
-
== 1.
|
1
|
+
== 1.2.rc
|
2
2
|
|
3
|
-
*
|
4
|
-
*
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
*
|
9
|
-
*
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
*
|
14
|
-
*
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
*
|
19
|
-
*
|
20
|
-
*
|
21
|
-
* Use
|
22
|
-
|
23
|
-
|
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
|
-
*
|
27
|
-
|
28
|
-
*
|
29
|
-
*
|
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
|
|
data/README.rdoc
CHANGED
@@ -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
|
-
|
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
|
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
|
-
==
|
25
|
+
== Information
|
24
26
|
|
25
|
-
|
27
|
+
=== The Devise Wiki
|
26
28
|
|
27
|
-
|
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
|
-
|
31
|
+
http://wiki.github.com/plataformatec/devise
|
30
32
|
|
31
|
-
|
33
|
+
=== Bug reports
|
32
34
|
|
33
|
-
|
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
|
-
|
37
|
+
http://github.com/plataformatec/devise/wiki/Bug-reports
|
36
38
|
|
37
|
-
|
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
|
-
|
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
|
-
|
49
|
+
You can view the Devise documentation in RDoc format here:
|
42
50
|
|
43
|
-
|
51
|
+
http://rubydoc.info/github/plataformatec/devise/master/frames
|
44
52
|
|
45
|
-
|
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
|
-
|
55
|
+
=== Example Applications
|
48
56
|
|
49
|
-
|
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
|
-
|
59
|
+
http://github.com/plataformatec/devise/wiki/Example-Applications
|
52
60
|
|
53
|
-
|
61
|
+
=== Extensions
|
54
62
|
|
55
|
-
|
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
|
-
|
65
|
+
http://github.com/plataformatec/devise/wiki/Extensions
|
59
66
|
|
60
|
-
|
67
|
+
=== Contributing
|
61
68
|
|
62
|
-
|
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
|
-
|
71
|
+
http://github.com/plataformatec/devise/wiki/Contributing
|
66
72
|
|
67
|
-
|
68
|
-
|
69
|
-
|
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
|
-
|
81
|
+
rails generate devise:install
|
72
82
|
|
73
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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 => "
|
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
|
-
|
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
|
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:
|
228
|
-
|
229
|
-
|
230
|
-
|
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
|
-
|
283
|
+
http://github.com/plataformatec/devise/wiki/I18n
|
233
284
|
|
234
|
-
|
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
|
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
|
-
|
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
|
-
|
257
|
-
|
258
|
-
|
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
|
-
|
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
|
-
|
309
|
+
=== OAuth2
|
269
310
|
|
270
|
-
|
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
|
-
|
313
|
+
* http://github.com/plataformatec/devise/wiki/OAuth2:-Overview
|
314
|
+
* http://github.com/plataformatec/devise/wiki/OAuth2:-Testing
|
273
315
|
|
274
|
-
|
316
|
+
=== Other ORMs
|
275
317
|
|
276
|
-
|
318
|
+
Devise supports ActiveRecord (default) and Mongoid. To choose other ORM, you just need to require it in the initializer file.
|
277
319
|
|
278
|
-
|
320
|
+
=== Migrating from other solutions
|
279
321
|
|
280
|
-
|
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
|
-
|
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
|
-
|
326
|
+
=== Warden
|
287
327
|
|
288
|
-
|
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
|
-
|
291
|
-
* Carlos Antônio da Silva (http://github.com/carlosantoniodasilva)
|
330
|
+
http://github.com/hassox/warden
|
292
331
|
|
293
|
-
|
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
|
-
|
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
|
-
|
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
|
|
@@ -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
|