devise 1.3.4 → 1.4.1

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 (74) hide show
  1. data/.travis.yml +3 -2
  2. data/CHANGELOG.rdoc +29 -0
  3. data/Gemfile +10 -7
  4. data/Gemfile.lock +47 -47
  5. data/README.rdoc +2 -2
  6. data/Rakefile +1 -1
  7. data/app/controllers/devise/confirmations_controller.rb +2 -2
  8. data/app/controllers/devise/passwords_controller.rb +10 -2
  9. data/app/controllers/devise/registrations_controller.rb +6 -4
  10. data/app/controllers/devise/unlocks_controller.rb +2 -2
  11. data/app/helpers/devise_helper.rb +1 -1
  12. data/app/mailers/devise/mailer.rb +4 -77
  13. data/config/locales/en.yml +3 -0
  14. data/lib/devise.rb +45 -13
  15. data/lib/devise/controllers/helpers.rb +5 -2
  16. data/lib/devise/controllers/internal_helpers.rb +15 -1
  17. data/lib/devise/controllers/rememberable.rb +1 -1
  18. data/lib/devise/email.rb +23 -0
  19. data/lib/devise/hooks/forgetable.rb +1 -1
  20. data/lib/devise/hooks/trackable.rb +1 -1
  21. data/lib/devise/mailers/helpers.rb +84 -0
  22. data/lib/devise/mapping.rb +23 -7
  23. data/lib/devise/models/authenticatable.rb +14 -6
  24. data/lib/devise/models/database_authenticatable.rb +18 -1
  25. data/lib/devise/models/recoverable.rb +1 -1
  26. data/lib/devise/models/rememberable.rb +7 -5
  27. data/lib/devise/models/validatable.rb +5 -7
  28. data/lib/devise/modules.rb +1 -1
  29. data/lib/devise/omniauth.rb +0 -5
  30. data/lib/devise/omniauth/config.rb +6 -0
  31. data/lib/devise/rails/routes.rb +65 -10
  32. data/lib/devise/strategies/rememberable.rb +2 -7
  33. data/lib/devise/version.rb +1 -1
  34. data/lib/generators/devise/install_generator.rb +2 -2
  35. data/lib/generators/devise/simple_form_for/confirmations/new.html.erb +15 -0
  36. data/lib/generators/devise/simple_form_for/passwords/edit.html.erb +19 -0
  37. data/lib/generators/devise/simple_form_for/passwords/new.html.erb +15 -0
  38. data/lib/generators/devise/simple_form_for/registrations/edit.html.erb +22 -0
  39. data/lib/generators/devise/simple_form_for/registrations/new.html.erb +17 -0
  40. data/lib/generators/devise/simple_form_for/sessions/new.html.erb +15 -0
  41. data/lib/generators/devise/simple_form_for/unlocks/new.html.erb +15 -0
  42. data/lib/generators/devise/views_generator.rb +61 -9
  43. data/lib/generators/templates/devise.rb +13 -3
  44. data/test/controllers/internal_helpers_test.rb +9 -2
  45. data/test/generators/views_generator_test.rb +10 -0
  46. data/test/helpers/devise_helper_test.rb +43 -0
  47. data/test/integration/authenticatable_test.rb +74 -5
  48. data/test/integration/confirmable_test.rb +39 -1
  49. data/test/integration/database_authenticatable_test.rb +22 -0
  50. data/test/integration/http_authenticatable_test.rb +8 -0
  51. data/test/integration/lockable_test.rb +62 -4
  52. data/test/integration/omniauthable_test.rb +1 -3
  53. data/test/integration/recoverable_test.rb +66 -6
  54. data/test/integration/registerable_test.rb +1 -1
  55. data/test/integration/rememberable_test.rb +20 -1
  56. data/test/integration/trackable_test.rb +17 -0
  57. data/test/mapping_test.rb +5 -0
  58. data/test/models/database_authenticatable_test.rb +56 -1
  59. data/test/models/encryptable_test.rb +1 -1
  60. data/test/models/recoverable_test.rb +14 -3
  61. data/test/models/rememberable_test.rb +8 -0
  62. data/test/models/token_authenticatable_test.rb +0 -6
  63. data/test/models/validatable_test.rb +17 -4
  64. data/test/models_test.rb +4 -0
  65. data/test/omniauth/url_helpers_test.rb +4 -0
  66. data/test/rails_app/app/controllers/home_controller.rb +9 -0
  67. data/test/rails_app/app/controllers/users_controller.rb +6 -1
  68. data/test/rails_app/app/views/home/admin_dashboard.html.erb +1 -0
  69. data/test/rails_app/app/views/home/join.html.erb +1 -0
  70. data/test/rails_app/app/views/home/user_dashboard.html.erb +1 -0
  71. data/test/rails_app/config/initializers/devise.rb +6 -0
  72. data/test/rails_app/config/routes.rb +30 -2
  73. data/test/routes_test.rb +54 -0
  74. metadata +21 -4
@@ -1,5 +1,6 @@
1
1
  class UsersController < ApplicationController
2
- before_filter :authenticate_user!, :except => :accept
2
+ prepend_before_filter :current_user, :only => :exhibit
3
+ before_filter :authenticate_user!, :except => [:accept, :exhibit]
3
4
  respond_to :html, :xml
4
5
 
5
6
  def index
@@ -11,6 +12,10 @@ class UsersController < ApplicationController
11
12
  @current_user = current_user
12
13
  end
13
14
 
15
+ def exhibit
16
+ render :text => current_user ? "User is authenticated" : "User is not authenticated"
17
+ end
18
+
14
19
  def expire
15
20
  user_session['last_request_at'] = 31.minutes.ago.utc
16
21
  render :text => 'User will be expired on next request'
@@ -0,0 +1 @@
1
+ Admin dashboard
@@ -0,0 +1 @@
1
+ Join
@@ -0,0 +1 @@
1
+ User dashboard
@@ -35,6 +35,11 @@ Devise.setup do |config|
35
35
  # These keys will be downcased upon creating or modifying a user and when used
36
36
  # to authenticate or find a user. Default is :email.
37
37
  config.case_insensitive_keys = [ :email ]
38
+
39
+ # Configure which authentication keys should have whitespace stripped.
40
+ # These keys will have whitespace before and after removed upon creating or
41
+ # modifying a user and when used to authenticate or find a user. Default is :email.
42
+ config.strip_whitespace_keys = [ :email ]
38
43
 
39
44
  # Tell if authentication through request.params is enabled. True by default.
40
45
  # config.params_authenticatable = true
@@ -172,6 +177,7 @@ Devise.setup do |config|
172
177
  # ==> OmniAuth
173
178
  config.omniauth :facebook, 'APP_ID', 'APP_SECRET', :scope => 'email,offline_access'
174
179
  config.omniauth :open_id
180
+ config.omniauth :open_id, :name => 'google', :identifier => 'https://www.google.com/accounts/o8/id'
175
181
 
176
182
  # ==> Warden configuration
177
183
  # If you want to use other strategies, that are not supported by Devise, or
@@ -3,6 +3,10 @@ Rails.application.routes.draw do
3
3
  resources :users, :only => [:index] do
4
4
  get :expire, :on => :member
5
5
  get :accept, :on => :member
6
+
7
+ authenticate :user do
8
+ post :exhibit, :on => :member
9
+ end
6
10
  end
7
11
 
8
12
  resources :admins, :only => [:index]
@@ -19,7 +23,7 @@ Rails.application.routes.draw do
19
23
  match "/sign_in", :to => "devise/sessions#new"
20
24
 
21
25
  # Admin scope
22
- devise_for :admin, :path => "admin_area", :controllers => { :sessions => "admins/sessions" }, :skip => :passwords
26
+ devise_for :admin, :path => "admin_area", :controllers => { :sessions => :"admins/sessions" }, :skip => :passwords
23
27
 
24
28
  match "/admin_area/home", :to => "admins#index", :as => :admin_root
25
29
  match "/anywhere", :to => "foo#bar", :as => :new_admin_password
@@ -28,6 +32,29 @@ Rails.application.routes.draw do
28
32
  match "/private", :to => "home#private", :as => :private
29
33
  end
30
34
 
35
+ authenticated :admin do
36
+ match "/dashboard", :to => "home#admin_dashboard"
37
+ end
38
+
39
+ authenticated do
40
+ match "/dashboard", :to => "home#user_dashboard"
41
+ end
42
+
43
+ unauthenticated do
44
+ match "/join", :to => "home#join"
45
+ end
46
+
47
+ # Routes for constraints testing
48
+ devise_for :headquarters_admin, :class_name => "Admin", :path => "headquarters", :constraints => {:host => /192\.168\.1\.\d\d\d/}
49
+
50
+ constraints(:host => /192\.168\.1\.\d\d\d/) do
51
+ devise_for :homebase_admin, :class_name => "Admin", :path => "homebase"
52
+ end
53
+
54
+ # Routes for format=false testing
55
+ devise_for :htmlonly_admin, :class_name => "Admin", :skip => [:confirmations, :unlocks], :path => "htmlonly_admin", :format => false
56
+ devise_for :htmlonly_users, :class_name => "User", :only => [:confirmations, :unlocks], :path => "htmlonly_users", :format => false
57
+
31
58
  # Other routes for routing_test.rb
32
59
  devise_for :reader, :class_name => "User", :only => :passwords
33
60
 
@@ -53,5 +80,6 @@ Rails.application.routes.draw do
53
80
 
54
81
  match "/set", :to => "home#set"
55
82
  match "/unauthenticated", :to => "home#unauthenticated"
83
+
56
84
  root :to => "home#index"
57
- end
85
+ end
data/test/routes_test.rb CHANGED
@@ -96,6 +96,11 @@ class DefaultRoutingTest < ActionController::TestCase
96
96
  assert_recognizes({:controller => 'users/omniauth_callbacks', :action => 'facebook'}, {:path => 'users/auth/facebook/callback', :method => :post})
97
97
  assert_named_route "/users/auth/facebook/callback", :user_omniauth_callback_path, :facebook
98
98
 
99
+ # named open_id
100
+ assert_recognizes({:controller => 'users/omniauth_callbacks', :action => 'google'}, {:path => 'users/auth/google/callback', :method => :get})
101
+ assert_recognizes({:controller => 'users/omniauth_callbacks', :action => 'google'}, {:path => 'users/auth/google/callback', :method => :post})
102
+ assert_named_route "/users/auth/google/callback", :user_omniauth_callback_path, :google
103
+
99
104
  assert_raise ActionController::RoutingError do
100
105
  assert_recognizes({:controller => 'ysers/omniauth_callbacks', :action => 'twitter'}, {:path => 'users/auth/twitter/callback', :method => :get})
101
106
  end
@@ -171,6 +176,55 @@ class CustomizedRoutingTest < ActionController::TestCase
171
176
  assert_recognizes({:controller => 'devise/sessions', :action => 'destroy'}, {:path => '/sign_out_via/delete_or_posts/sign_out', :method => :get})
172
177
  end
173
178
  end
179
+
180
+ test 'map with constraints defined in hash' do
181
+ assert_recognizes({:controller => 'devise/registrations', :action => 'new'}, {:path => 'http://192.168.1.100/headquarters/sign_up', :method => :get})
182
+ assert_raise ActionController::RoutingError do
183
+ assert_recognizes({:controller => 'devise/registrations', :action => 'new'}, {:path => 'http://10.0.0.100/headquarters/sign_up', :method => :get})
184
+ end
185
+ end
186
+
187
+ test 'map with constraints defined in block' do
188
+ assert_recognizes({:controller => 'devise/registrations', :action => 'new'}, {:path => 'http://192.168.1.100/homebase/sign_up', :method => :get})
189
+ assert_raise ActionController::RoutingError do
190
+ assert_recognizes({:controller => 'devise/registrations', :action => 'new'}, {:path => 'http://10.0.0.100//homebase/sign_up', :method => :get})
191
+ end
192
+ end
193
+
194
+ test 'map with format false for sessions' do
195
+ assert_recognizes({:controller => 'devise/sessions', :action => 'new'}, {:path => '/htmlonly_admin/sign_in', :method => :get})
196
+ assert_raise ActionController::RoutingError do
197
+ assert_recognizes({:controller => 'devise/sessions', :action => 'new'}, {:path => '/htmlonly_admin/sign_in.xml', :method => :get})
198
+ end
199
+ end
200
+
201
+ test 'map with format false for passwords' do
202
+ assert_recognizes({:controller => 'devise/passwords', :action => 'create'}, {:path => '/htmlonly_admin/password', :method => :post})
203
+ assert_raise ActionController::RoutingError do
204
+ assert_recognizes({:controller => 'devise/passwords', :action => 'create'}, {:path => '/htmlonly_admin/password.xml', :method => :post})
205
+ end
206
+ end
207
+
208
+ test 'map with format false for registrations' do
209
+ assert_recognizes({:controller => 'devise/registrations', :action => 'new'}, {:path => '/htmlonly_admin/sign_up', :method => :get})
210
+ assert_raise ActionController::RoutingError do
211
+ assert_recognizes({:controller => 'devise/registrations', :action => 'new'}, {:path => '/htmlonly_admin/sign_up.xml', :method => :get})
212
+ end
213
+ end
214
+
215
+ test 'map with format false for confirmations' do
216
+ assert_recognizes({:controller => 'devise/confirmations', :action => 'show'}, {:path => '/htmlonly_users/confirmation', :method => :get})
217
+ assert_raise ActionController::RoutingError do
218
+ assert_recognizes({:controller => 'devise/confirmations', :action => 'show'}, {:path => '/htmlonly_users/confirmation.xml', :method => :get})
219
+ end
220
+ end
221
+
222
+ test 'map with format false for unlocks' do
223
+ assert_recognizes({:controller => 'devise/unlocks', :action => 'show'}, {:path => '/htmlonly_users/unlock', :method => :get})
224
+ assert_raise ActionController::RoutingError do
225
+ assert_recognizes({:controller => 'devise/unlocks', :action => 'show'}, {:path => '/htmlonly_users/unlock.xml', :method => :get})
226
+ end
227
+ end
174
228
  end
175
229
 
176
230
  class ScopedRoutingTest < ActionController::TestCase
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
- - 3
9
8
  - 4
10
- version: 1.3.4
9
+ - 1
10
+ version: 1.4.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Jos\xC3\xA9 Valim"
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-04-29 00:00:00 +02:00
19
+ date: 2011-06-29 00:00:00 -03:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -112,6 +112,7 @@ files:
112
112
  - lib/devise/controllers/scoped_views.rb
113
113
  - lib/devise/controllers/shared_helpers.rb
114
114
  - lib/devise/controllers/url_helpers.rb
115
+ - lib/devise/email.rb
115
116
  - lib/devise/encryptors/authlogic_sha512.rb
116
117
  - lib/devise/encryptors/base.rb
117
118
  - lib/devise/encryptors/clearance_sha1.rb
@@ -124,6 +125,7 @@ files:
124
125
  - lib/devise/hooks/rememberable.rb
125
126
  - lib/devise/hooks/timeoutable.rb
126
127
  - lib/devise/hooks/trackable.rb
128
+ - lib/devise/mailers/helpers.rb
127
129
  - lib/devise/mapping.rb
128
130
  - lib/devise/models.rb
129
131
  - lib/devise/models/authenticatable.rb
@@ -162,6 +164,13 @@ files:
162
164
  - lib/generators/devise/devise_generator.rb
163
165
  - lib/generators/devise/install_generator.rb
164
166
  - lib/generators/devise/orm_helpers.rb
167
+ - lib/generators/devise/simple_form_for/confirmations/new.html.erb
168
+ - lib/generators/devise/simple_form_for/passwords/edit.html.erb
169
+ - lib/generators/devise/simple_form_for/passwords/new.html.erb
170
+ - lib/generators/devise/simple_form_for/registrations/edit.html.erb
171
+ - lib/generators/devise/simple_form_for/registrations/new.html.erb
172
+ - lib/generators/devise/simple_form_for/sessions/new.html.erb
173
+ - lib/generators/devise/simple_form_for/unlocks/new.html.erb
165
174
  - lib/generators/devise/views_generator.rb
166
175
  - lib/generators/mongoid/devise_generator.rb
167
176
  - lib/generators/templates/README
@@ -178,6 +187,7 @@ files:
178
187
  - test/generators/install_generator_test.rb
179
188
  - test/generators/mongoid_generator_test.rb
180
189
  - test/generators/views_generator_test.rb
190
+ - test/helpers/devise_helper_test.rb
181
191
  - test/indifferent_hash.rb
182
192
  - test/integration/authenticatable_test.rb
183
193
  - test/integration/confirmable_test.rb
@@ -227,8 +237,11 @@ files:
227
237
  - test/rails_app/app/mongoid/user.rb
228
238
  - test/rails_app/app/views/admins/index.html.erb
229
239
  - test/rails_app/app/views/admins/sessions/new.html.erb
240
+ - test/rails_app/app/views/home/admin_dashboard.html.erb
230
241
  - test/rails_app/app/views/home/index.html.erb
242
+ - test/rails_app/app/views/home/join.html.erb
231
243
  - test/rails_app/app/views/home/private.html.erb
244
+ - test/rails_app/app/views/home/user_dashboard.html.erb
232
245
  - test/rails_app/app/views/layouts/application.html.erb
233
246
  - test/rails_app/app/views/users/index.html.erb
234
247
  - test/rails_app/app/views/users/mailer/confirmation_instructions.erb
@@ -311,6 +324,7 @@ test_files:
311
324
  - test/generators/install_generator_test.rb
312
325
  - test/generators/mongoid_generator_test.rb
313
326
  - test/generators/views_generator_test.rb
327
+ - test/helpers/devise_helper_test.rb
314
328
  - test/indifferent_hash.rb
315
329
  - test/integration/authenticatable_test.rb
316
330
  - test/integration/confirmable_test.rb
@@ -360,8 +374,11 @@ test_files:
360
374
  - test/rails_app/app/mongoid/user.rb
361
375
  - test/rails_app/app/views/admins/index.html.erb
362
376
  - test/rails_app/app/views/admins/sessions/new.html.erb
377
+ - test/rails_app/app/views/home/admin_dashboard.html.erb
363
378
  - test/rails_app/app/views/home/index.html.erb
379
+ - test/rails_app/app/views/home/join.html.erb
364
380
  - test/rails_app/app/views/home/private.html.erb
381
+ - test/rails_app/app/views/home/user_dashboard.html.erb
365
382
  - test/rails_app/app/views/layouts/application.html.erb
366
383
  - test/rails_app/app/views/users/index.html.erb
367
384
  - test/rails_app/app/views/users/mailer/confirmation_instructions.erb