devise 1.0.11 → 1.1.pre

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 +6 -72
  2. data/Gemfile +18 -0
  3. data/README.rdoc +51 -46
  4. data/Rakefile +5 -4
  5. data/app/controllers/{confirmations_controller.rb → devise/confirmations_controller.rb} +2 -2
  6. data/app/controllers/{passwords_controller.rb → devise/passwords_controller.rb} +4 -3
  7. data/app/controllers/{registrations_controller.rb → devise/registrations_controller.rb} +11 -7
  8. data/app/controllers/{sessions_controller.rb → devise/sessions_controller.rb} +11 -8
  9. data/app/controllers/{unlocks_controller.rb → devise/unlocks_controller.rb} +2 -10
  10. data/app/models/devise/mailer.rb +55 -0
  11. data/app/views/{confirmations → devise/confirmations}/new.html.erb +1 -1
  12. data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
  13. data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  14. data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  15. data/app/views/{passwords → devise/passwords}/edit.html.erb +1 -1
  16. data/app/views/{passwords → devise/passwords}/new.html.erb +1 -1
  17. data/app/views/{registrations → devise/registrations}/edit.html.erb +1 -1
  18. data/app/views/{registrations → devise/registrations}/new.html.erb +1 -1
  19. data/app/views/{sessions → devise/sessions}/new.html.erb +1 -1
  20. data/app/views/{shared/_devise_links.erb → devise/shared/_links.erb} +0 -0
  21. data/app/views/{unlocks → devise/unlocks}/new.html.erb +1 -1
  22. data/{lib/devise → config}/locales/en.yml +7 -1
  23. data/lib/devise.rb +6 -29
  24. data/lib/devise/controllers/helpers.rb +16 -43
  25. data/lib/devise/controllers/internal_helpers.rb +10 -36
  26. data/lib/devise/controllers/scoped_views.rb +35 -0
  27. data/lib/devise/failure_app.rb +7 -14
  28. data/lib/devise/hooks/rememberable.rb +3 -6
  29. data/lib/devise/hooks/trackable.rb +1 -1
  30. data/lib/devise/mapping.rb +17 -18
  31. data/lib/devise/models.rb +4 -20
  32. data/lib/devise/models/{database_authenticatable.rb → authenticatable.rb} +16 -28
  33. data/lib/devise/models/confirmable.rb +25 -23
  34. data/lib/devise/models/http_authenticatable.rb +3 -7
  35. data/lib/devise/models/lockable.rb +40 -35
  36. data/lib/devise/models/recoverable.rb +4 -8
  37. data/lib/devise/models/rememberable.rb +6 -9
  38. data/lib/devise/models/timeoutable.rb +1 -3
  39. data/lib/devise/models/token_authenticatable.rb +4 -5
  40. data/lib/devise/models/validatable.rb +10 -1
  41. data/lib/devise/orm/mongo_mapper.rb +10 -23
  42. data/lib/devise/rails.rb +11 -9
  43. data/lib/devise/rails/routes.rb +113 -107
  44. data/lib/devise/rails/warden_compat.rb +3 -41
  45. data/lib/devise/schema.rb +13 -21
  46. data/lib/devise/strategies/{database_authenticatable.rb → authenticatable.rb} +3 -3
  47. data/lib/devise/strategies/http_authenticatable.rb +4 -22
  48. data/lib/devise/test_helpers.rb +1 -8
  49. data/lib/devise/version.rb +1 -1
  50. data/lib/generators/devise/devise_generator.rb +57 -0
  51. data/{generators → lib/generators}/devise/templates/migration.rb +1 -1
  52. data/lib/generators/devise_install/devise_install_generator.rb +25 -0
  53. data/{generators → lib/generators}/devise_install/templates/README +4 -8
  54. data/{generators → lib/generators}/devise_install/templates/devise.rb +0 -3
  55. data/lib/generators/devise_views/devise_views_generator.rb +11 -0
  56. data/test/controllers/helpers_test.rb +15 -9
  57. data/test/devise_test.rb +1 -6
  58. data/test/encryptors_test.rb +0 -3
  59. data/test/failure_app_test.rb +6 -1
  60. data/test/integration/authenticatable_test.rb +25 -85
  61. data/test/integration/http_authenticatable_test.rb +2 -10
  62. data/test/integration/lockable_test.rb +3 -22
  63. data/test/integration/recoverable_test.rb +1 -1
  64. data/test/integration/registerable_test.rb +31 -36
  65. data/test/integration/rememberable_test.rb +6 -24
  66. data/test/integration/token_authenticatable_test.rb +2 -4
  67. data/test/integration/trackable_test.rb +1 -1
  68. data/test/mailers/confirmation_instructions_test.rb +4 -10
  69. data/test/mailers/unlock_instructions_test.rb +1 -1
  70. data/test/mapping_test.rb +12 -24
  71. data/test/models/authenticatable_test.rb +3 -3
  72. data/test/models/confirmable_test.rb +29 -29
  73. data/test/models/http_authenticatable_test.rb +19 -0
  74. data/test/models/lockable_test.rb +45 -44
  75. data/test/models/recoverable_test.rb +7 -7
  76. data/test/models/rememberable_test.rb +7 -10
  77. data/test/models/validatable_test.rb +19 -24
  78. data/test/models_test.rb +2 -16
  79. data/test/orm/active_record.rb +3 -4
  80. data/test/orm/mongo_mapper.rb +2 -10
  81. data/test/rails_app/app/active_record/admin.rb +1 -1
  82. data/test/rails_app/app/active_record/user.rb +3 -3
  83. data/test/rails_app/app/controllers/application_controller.rb +1 -7
  84. data/test/rails_app/app/controllers/sessions_controller.rb +6 -0
  85. data/test/rails_app/app/controllers/users_controller.rb +0 -4
  86. data/test/rails_app/app/mongo_mapper/admin.rb +4 -7
  87. data/test/rails_app/app/mongo_mapper/user.rb +5 -8
  88. data/test/rails_app/config/application.rb +32 -0
  89. data/test/rails_app/config/boot.rb +7 -108
  90. data/test/rails_app/config/environment.rb +4 -41
  91. data/test/rails_app/config/environments/development.rb +15 -13
  92. data/test/rails_app/config/environments/production.rb +25 -20
  93. data/test/rails_app/config/environments/test.rb +23 -22
  94. data/test/rails_app/config/initializers/backtrace_silencers.rb +7 -0
  95. data/test/rails_app/config/initializers/cookie_verification_secret.rb +7 -0
  96. data/test/rails_app/config/initializers/devise.rb +0 -3
  97. data/test/rails_app/config/initializers/session_store.rb +2 -2
  98. data/test/rails_app/config/routes.rb +17 -21
  99. data/test/routes_test.rb +30 -47
  100. data/test/support/{assertions_helper.rb → assertions.rb} +0 -15
  101. data/test/support/{tests_helper.rb → helpers.rb} +16 -3
  102. data/test/support/{integration_tests_helper.rb → integration.rb} +8 -4
  103. data/test/support/webrat/integrations/rails.rb +31 -0
  104. data/test/test_helper.rb +8 -7
  105. data/test/test_helpers_test.rb +9 -9
  106. metadata +53 -128
  107. data/app/models/devise_mailer.rb +0 -68
  108. data/app/views/devise_mailer/confirmation_instructions.html.erb +0 -5
  109. data/app/views/devise_mailer/reset_password_instructions.html.erb +0 -8
  110. data/app/views/devise_mailer/unlock_instructions.html.erb +0 -7
  111. data/generators/devise/USAGE +0 -5
  112. data/generators/devise/devise_generator.rb +0 -15
  113. data/generators/devise/lib/route_devise.rb +0 -32
  114. data/generators/devise/templates/model.rb +0 -9
  115. data/generators/devise_install/USAGE +0 -3
  116. data/generators/devise_install/devise_install_generator.rb +0 -15
  117. data/generators/devise_views/USAGE +0 -3
  118. data/generators/devise_views/devise_views_generator.rb +0 -21
  119. data/rails/init.rb +0 -2
  120. data/test/integration/rack_middleware_test.rb +0 -47
  121. data/test/rails_app/config/initializers/new_rails_defaults.rb +0 -24
@@ -1,78 +1,13 @@
1
- == 1.0.11
2
-
3
- * bug fix
4
- * Make sure xhr requests do not store urls for redirect
5
- * Squeeze break lines from cookies to avoid duplicated break lines
6
-
7
- == 1.0.10
8
-
9
- * bug fix
10
- * Use secure compare when comparing passwords
11
- * Improve email regexp
12
- * Implement handle_unverified_request for Rails 2.3.11
13
-
14
- == 1.0.9
1
+ == 1.1.pre
15
2
 
16
3
  * enhancements
17
- * Extracted redirect path from Devise failure app to a new method, allowing override in custom failure apps
18
- * Added sign_out_via
19
-
20
- * bug fix
21
- * Email is now case insensitive
22
- * Avoid session fixation attacks
23
-
24
- == 1.0.8
25
-
26
- * enhancements
27
- * Support for latest MongoMapper
28
- * Added anybody_signed_in? helper (by github.com/SSDany)
29
-
30
- * bug fix
31
- * confirmation_required? is properly honored on active? calls. (by github.com/paulrosania)
32
-
33
- == 1.0.7
34
-
35
- * bug fix
36
- * Ensure password confirmation is always required
4
+ * Rails 3 compatibility.
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.
37
7
 
38
8
  * deprecations
39
- * authenticatable was deprecated and renamed to database_authenticatable
40
- * confirmable is not included by default on generation
41
-
42
- == 1.0.6
43
-
44
- * bug fix
45
- * Do not allow unlockable strategies based on time to access a controller.
46
- * Do not send unlockable email several times.
47
- * Allow controller to upstram custom! failures to Warden.
48
-
49
- == 1.0.5
50
-
51
- * bug fix
52
- * Use prepend_before_filter in require_no_authentication.
53
- * require_no_authentication on unlockable.
54
- * Fix a bug when giving an association proxy to devise.
55
- * Do not use lock! on lockable since it's part of ActiveRecord API.
56
-
57
- == 1.0.4
58
-
59
- * bug fix
60
- * Fixed a bug when deleting an account with rememberable
61
- * Fixed a bug with custom controllers
62
-
63
- == 1.0.3
64
-
65
- * enhancements
66
- * HTML e-mails now have proper formatting
67
- * Do not remove MongoMapper options in find
68
-
69
- == 1.0.2
70
-
71
- * enhancements
72
- * Allows you set mailer content type (by github.com/glennr)
73
-
74
- * bug fix
75
- * Uses the same content type as request on http authenticatable 401 responses
9
+ * Rails 3 compatible only.
10
+ * Scoped views are no longer "sessions/users/new". Now use "users/sessions/new".
76
11
 
77
12
  == 1.0.1
78
13
 
@@ -93,7 +28,6 @@
93
28
  * Added Http Basic Authentication support
94
29
  * Allow scoped_views to be customized per controller/mailer class
95
30
  * [#99] Allow authenticatable to used in change_table statements
96
- * Add mailer_content_type configuration parameter (by github.com/glennr)
97
31
 
98
32
  == 0.9.2
99
33
 
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ source "http://gemcutter.org"
2
+
3
+ gem "rails", "3.0.0.beta"
4
+ gem "warden", "0.9.3"
5
+ gem "sqlite3-ruby", :require => "sqlite3"
6
+ gem "webrat", "0.7"
7
+ gem "mocha", :require => false
8
+ gem "bcrypt-ruby", :require => "bcrypt"
9
+
10
+ if RUBY_VERSION < '1.9'
11
+ gem "ruby-debug", ">= 0.10.3"
12
+ end
13
+
14
+ group :mongo_mapper do
15
+ gem "mongo", "0.18.3"
16
+ gem "mongo_ext", "0.18.3", :require => false
17
+ gem "mongo_mapper", "0.7.0"
18
+ end
@@ -9,7 +9,7 @@ Devise is a flexible authentication solution for Rails based on Warden. It:
9
9
 
10
10
  Right now it's composed of 12 modules:
11
11
 
12
- * Database Authenticatable: responsible for encrypting password and validating authenticity of a user while signing in.
12
+ * Authenticatable: responsible for encrypting password and validating authenticity of a user while signing in.
13
13
  * Token Authenticatable: validates authenticity of a user while signing in using an authentication token (also known as "single access token").
14
14
  * HttpAuthenticatable: sign in users using basic HTTP authentication.
15
15
  * Confirmable: responsible for verifying whether an account is already confirmed to sign in, and to send emails with confirmation instructions.
@@ -30,30 +30,32 @@ Devise is based on Warden (http://github.com/hassox/warden), a Rack Authenticati
30
30
 
31
31
  == Installation
32
32
 
33
- Install warden gem if you don't have it installed:
33
+ Devise master branch now supports Rails 3 and is NOT backward compatible. You can install it as:
34
34
 
35
- gem install warden
35
+ sudo gem install devise --version=1.1.pre
36
36
 
37
- Install devise gem:
37
+ After installing them, you need configure warden and devise gems inside your gemfile:
38
38
 
39
- gem install devise --version=1.0.10
39
+ gem 'warden'
40
+ gem 'devise'
40
41
 
41
- Configure warden and devise gems inside your app:
42
+ And run the generator:
42
43
 
43
- config.gem 'warden'
44
- config.gem 'devise'
44
+ rails generate devise_install
45
45
 
46
- Run the generator:
46
+ 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:
47
47
 
48
- ruby script/generate devise_install
48
+ http://rdoc.info/projects/plataformatec/devise
49
49
 
50
- 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 the documentation as well:
50
+ == Rails 2.3
51
51
 
52
- http://rdoc.info/projects/plataformatec/devise
52
+ If you want to use the Rails 2.3.x version, you should do:
53
53
 
54
- If you want to use Devise with bundler on Rails 2.3, you need to follow the instructions here:
54
+ sudo gem install devise --version=1.0.1
55
55
 
56
- http://github.com/carlhuda/bundler/issues/issue/83
56
+ Or checkout from the v1.0 branch:
57
+
58
+ http://github.com/plataformatec/devise/tree/v1.0
57
59
 
58
60
  == Basic Usage
59
61
 
@@ -64,13 +66,13 @@ Devise must be set up within the model (or models) you want to use, and devise r
64
66
  We're assuming here you want a User model with some modules, as outlined below:
65
67
 
66
68
  class User < ActiveRecord::Base
67
- devise :database_authenticatable, :confirmable, :recoverable, :rememberable, :trackable, :validatable
69
+ devise :authenticatable, :confirmable, :recoverable, :rememberable, :trackable, :validatable
68
70
  end
69
71
 
70
72
  After you choose which modules to use, you need to setup your migrations. Luckily, devise has some helpers to save you from this boring work:
71
73
 
72
74
  create_table :users do |t|
73
- t.database_authenticatable
75
+ t.authenticatable
74
76
  t.confirmable
75
77
  t.recoverable
76
78
  t.rememberable
@@ -82,13 +84,13 @@ Remember that Devise don't rely on _attr_accessible_ or _attr_protected_ inside
82
84
 
83
85
  The next setup after setting up your model is to configure your routes. You do this by opening up your config/routes.rb and adding:
84
86
 
85
- map.devise_for :users
87
+ devise_for :users
86
88
 
87
89
  This is going to look inside you User model and create a set of needed routes (you can see them by running `rake routes`).
88
90
 
89
91
  There are also some options available for configuring your routes, as :class_name (to set the class for that route), :path_prefix, :as and :path_names, where the last two have the same meaning as in common routes. The available :path_names are:
90
92
 
91
- map.devise_for :users, :as => "usuarios", :path_names => { :sign_in => 'login', :sign_out => 'logout', :password => 'secret', :confirmation => 'verification', :unlock => 'unblock' }
93
+ devise_for :users, :as => "usuarios", :path_names => { :sign_in => 'login', :sign_out => 'logout', :password => 'secret', :confirmation => 'verification', :unlock => 'unblock' }
92
94
 
93
95
  Be sure to check devise_for documentation for detailed description.
94
96
 
@@ -114,7 +116,7 @@ You have also access to the session for this scope:
114
116
 
115
117
  After signing in a user, confirming it's account or updating it's password, devise will look for a scoped root path to redirect. Example: For a :user resource, it will use user_root_path if it exists, otherwise default root_path will be used. This means that you need to set the root inside your routes:
116
118
 
117
- map.root :controller => 'home'
119
+ root :to => "home"
118
120
 
119
121
  You can also overwrite after_sign_in_path_for and after_sign_out_path_for to customize better your redirect hooks.
120
122
 
@@ -128,16 +130,16 @@ Devise let's you setup as many roles as you want, so let's say you already have
128
130
 
129
131
  # Create a migration with the required fields
130
132
  create_table :admins do |t|
131
- t.database_authenticatable
133
+ t.authenticatable
132
134
  t.lockable
133
135
  t.trackable
134
136
  end
135
137
 
136
138
  # Inside your Admin model
137
- devise :database_authenticatable, :trackable, :timeoutable, :lockable
139
+ devise :authenticatable, :trackable, :timeoutable, :lockable
138
140
 
139
141
  # Inside your routes
140
- map.devise_for :admin
142
+ devise_for :admin
141
143
 
142
144
  # Inside your protected controller
143
145
  before_filter :authenticate_admin!
@@ -151,33 +153,48 @@ Devise let's you setup as many roles as you want, so let's say you already have
151
153
 
152
154
  Devise comes with some generators to help you start:
153
155
 
154
- ruby script/generate devise_install
156
+ rails generate devise_install
155
157
 
156
158
  This will generate an initializer, with a description of all configuration values. You can also generate models through:
157
159
 
158
- ruby script/generate devise Model
160
+ rails generate devise Model
159
161
 
160
162
  A model configured with all devise modules and attr_accessible for default fields will be created. The generator will also create the migration and configure your routes for devise.
161
163
 
162
164
  == Model configuration
163
165
 
164
- The devise method in your models also accept some options to configure its modules. For example, you can chose which encryptor to use in database_authenticatable:
166
+ The devise method in your models also accept some options to configure its modules. For example, you can chose which encryptor to use in authenticatable simply doing:
167
+
168
+ devise :authenticatable, :confirmable, :recoverable, :encryptor => :bcrypt
169
+
170
+ Besides :encryptor, you can provide :pepper, :stretches, :confirm_within, :remember_for, :timeout_in, :unlock_in and others. All those are described in the initializer created when you invoke the devise_install generator describer above.
171
+
172
+ == Configuring controllers and views
173
+
174
+ One of Devise goals is to help you bootstrap your application with authentication really fast. Another goal is to not be in your way when you need to customize it.
175
+
176
+ Since devise is an engine, it has all default views inside the gem. They are good to get you started, but you will want to customize them at some point. And Devise has a generator to copy them all to your application:
165
177
 
166
- devise :database_authenticatable, :confirmable, :recoverable, :encryptor => :bcrypt
178
+ rails generate devise_views
167
179
 
168
- Besides :encryptor, you can provide :pepper, :stretches, :confirm_within, :remember_for, :timeout_in, :unlock_in and others. All those are describer in the initializer created when you invoke the devise_install generator describer above.
180
+ If you have more than one role in your application, you will notice that Devise uses the same views for all roles you have. But what if you need so different views to each of them? Devise also has an easy way to accomplish it: just setup config.scoped_views to true inside "config/initializers/devise.rb".
169
181
 
170
- == Views
182
+ After doing so you will be able to have views based on the scope like "users/sessions/new" and "admins/sessions/new". If no view is found within the scope, Devise will fallback to the default view at "devise/sessions/new".
171
183
 
172
- Since devise is an engine, it has all default views inside the gem. They are good to get you started, but you will want to customize them at some point. And Devise has a generator to make copy them all to your application:
184
+ Finally, if the customization at the views level is not enough, you can customize each controller by following these steps:
173
185
 
174
- ruby script/generate devise_views
186
+ 1) Create your custom controller, for example a Admins::SessionsController:
175
187
 
176
- By default Devise will use the same views for all roles you have. But what if you need so different views to each of them? Devise also has an easy way to accomplish it: just setup config.scoped_views to true inside "config/initializers/devise.rb".
188
+ class Admins::SessionsController < Devise::SessionsController
189
+ end
177
190
 
178
- After doing so you will be able to have views based on the scope like 'sessions/users/new' and 'sessions/admin/new'. If no view is found within the scope, Devise will fallback to the default view.
191
+ 2) Tell the router to use this controller:
179
192
 
180
- Devise uses flash messages to let users know if their login is successful or not. Devise expects your application to call 'flash[:notice]' and 'flash[:alert]' as appropriate.
193
+ devise_for :admins, :controllers => { :sessions = "admin/sessions" }
194
+
195
+ 3) And finally, since we changed the controller, it won't use "devise/sessions" as views anymore, so remember to make a copy of "devise/sessions" to "admin/sessions".
196
+
197
+ Remember that Devise uses flash messages to let users know if sign in wass successful or not. Devise expects your application to call "flash[:notice]" and "flash[:alert]" as appropriate.
181
198
 
182
199
  == I18n
183
200
 
@@ -240,16 +257,6 @@ Devise supports both ActiveRecord (default) and MongoMapper, and has experimenta
240
257
 
241
258
  Please refer to TODO file.
242
259
 
243
- == Security
244
-
245
- 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:
246
-
247
- 1) Look at the source code a bit to find out whether your assumptions are correct;
248
- 2) If possible, provide a way to reproduce the bug: a small app on Github or a step-by-step to reproduce;
249
- 3) E-mail us or send a Github private message instead of using the normal issues;
250
-
251
- Being able to reproduce the bug is the first step to fix it. Thanks for your understanding.
252
-
253
260
  == Maintainers
254
261
 
255
262
  * José Valim (http://github.com/josevalim)
@@ -257,9 +264,7 @@ Being able to reproduce the bug is the first step to fix it. Thanks for your und
257
264
 
258
265
  == Contributors
259
266
 
260
- We have a long running list of contributors. Check them all here:
261
-
262
- http://github.com/plataformatec/devise/contributors
267
+ We have a long running list of contributors. Check them in the CHANGELOG or do `git shortlog -s -n` in the cloned repository.
263
268
 
264
269
  == Bugs and Feedback
265
270
 
data/Rakefile CHANGED
@@ -37,17 +37,18 @@ begin
37
37
  require 'jeweler'
38
38
  Jeweler::Tasks.new do |s|
39
39
  s.name = "devise"
40
- s.version = Devise::VERSION.dup
40
+ s.version = Devise::VERSION
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"
44
44
  s.description = "Flexible authentication solution for Rails with Warden"
45
45
  s.authors = ['José Valim', 'Carlos Antônio']
46
- s.files = FileList["[A-Z]*", "{app,config,generators,lib}/**/*", "rails/init.rb"]
47
- s.add_dependency("warden", "~> 0.10.3")
46
+ s.files = FileList["[A-Z]*", "{app,config,lib}/**/*"]
47
+ s.extra_rdoc_files = FileList["[A-Z]*"] - %w(Gemfile Rakefile)
48
+ s.add_dependency("warden", "~> 0.9.3")
48
49
  end
49
50
 
50
51
  Jeweler::GemcutterTasks.new
51
52
  rescue LoadError
52
- puts "Jeweler, or one of its dependencies, is not available. Install it with: gem install jeweler"
53
+ puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
53
54
  end
@@ -1,4 +1,4 @@
1
- class ConfirmationsController < ApplicationController
1
+ class Devise::ConfirmationsController < ApplicationController
2
2
  include Devise::Controllers::InternalHelpers
3
3
 
4
4
  # GET /resource/confirmation/new
@@ -21,7 +21,7 @@ class ConfirmationsController < ApplicationController
21
21
 
22
22
  # GET /resource/confirmation?confirmation_token=abcdef
23
23
  def show
24
- self.resource = resource_class.confirm_by_token(params[:confirmation_token])
24
+ self.resource = resource_class.confirm!(:confirmation_token => params[:confirmation_token])
25
25
 
26
26
  if resource.errors.empty?
27
27
  set_flash_message :notice, :confirmed
@@ -1,7 +1,8 @@
1
- class PasswordsController < ApplicationController
2
- prepend_before_filter :require_no_authentication
1
+ class Devise::PasswordsController < ApplicationController
3
2
  include Devise::Controllers::InternalHelpers
4
3
 
4
+ before_filter :require_no_authentication
5
+
5
6
  # GET /resource/password/new
6
7
  def new
7
8
  build_resource
@@ -29,7 +30,7 @@ class PasswordsController < ApplicationController
29
30
 
30
31
  # PUT /resource/password
31
32
  def update
32
- self.resource = resource_class.reset_password_by_token(params[resource_name])
33
+ self.resource = resource_class.reset_password!(params[resource_name])
33
34
 
34
35
  if resource.errors.empty?
35
36
  set_flash_message :notice, :updated
@@ -1,19 +1,21 @@
1
- class RegistrationsController < ApplicationController
2
- prepend_before_filter :require_no_authentication, :only => [ :new, :create ]
3
- prepend_before_filter :authenticate_scope!, :only => [:edit, :update, :destroy]
1
+ class Devise::RegistrationsController < ApplicationController
4
2
  include Devise::Controllers::InternalHelpers
5
3
 
6
- # GET /resource/sign_up
4
+ before_filter :require_no_authentication, :only => [ :new, :create ]
5
+ before_filter :authenticate_scope!, :only => [:edit, :update, :destroy]
6
+
7
+ # GET /resource/sign_in
7
8
  def new
8
9
  build_resource
9
10
  render_with_scope :new
10
11
  end
11
12
 
12
- # POST /resource
13
+ # POST /resource/sign_up
13
14
  def create
14
15
  build_resource
15
16
 
16
17
  if resource.save
18
+ flash[:"#{resource_name}_signed_up"] = true
17
19
  set_flash_message :notice, :signed_up
18
20
  sign_in_and_redirect(resource_name, resource)
19
21
  else
@@ -32,6 +34,8 @@ class RegistrationsController < ApplicationController
32
34
  set_flash_message :notice, :updated
33
35
  redirect_to after_sign_in_path_for(self.resource)
34
36
  else
37
+ build_resource
38
+ send(:"current_#{resource_name}").reload
35
39
  render_with_scope :edit
36
40
  end
37
41
  end
@@ -48,6 +52,6 @@ class RegistrationsController < ApplicationController
48
52
  # Authenticates the current scope and dup the resource
49
53
  def authenticate_scope!
50
54
  send(:"authenticate_#{resource_name}!")
51
- self.resource = send(:"current_#{resource_name}").dup
55
+ self.resource = send(:"current_#{resource_name}")
52
56
  end
53
- end
57
+ end
@@ -1,10 +1,11 @@
1
- class SessionsController < ApplicationController
2
- prepend_before_filter :require_no_authentication, :only => [ :new, :create ]
1
+ class Devise::SessionsController < ApplicationController
3
2
  include Devise::Controllers::InternalHelpers
4
3
 
4
+ before_filter :require_no_authentication, :only => [ :new, :create ]
5
+
5
6
  # GET /resource/sign_in
6
7
  def new
7
- unless flash[:notice].present?
8
+ unless resource_just_signed_up?
8
9
  Devise::FLASH_MESSAGES.each do |message|
9
10
  set_now_flash_message :alert, message if params.try(:[], message) == "true"
10
11
  end
@@ -19,8 +20,6 @@ class SessionsController < ApplicationController
19
20
  if resource = authenticate(resource_name)
20
21
  set_flash_message :notice, :signed_in
21
22
  sign_in_and_redirect(resource_name, resource, true)
22
- elsif [:custom, :redirect].include?(warden.result)
23
- throw :warden, :scope => resource_name
24
23
  else
25
24
  set_now_flash_message :alert, (warden.message || :invalid)
26
25
  clean_up_passwords(build_resource)
@@ -36,7 +35,11 @@ class SessionsController < ApplicationController
36
35
 
37
36
  protected
38
37
 
39
- def clean_up_passwords(object)
40
- object.clean_up_passwords if object.respond_to?(:clean_up_passwords)
41
- end
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
42
45
  end