devise 3.2.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


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

Files changed (187) hide show
  1. checksums.yaml +7 -0
  2. data/.travis.yml +18 -3
  3. data/CHANGELOG.md +82 -9
  4. data/CONTRIBUTING.md +2 -2
  5. data/Gemfile +7 -9
  6. data/Gemfile.lock +102 -96
  7. data/MIT-LICENSE +1 -1
  8. data/README.md +94 -42
  9. data/Rakefile +1 -1
  10. data/app/controllers/devise/confirmations_controller.rb +5 -3
  11. data/app/controllers/devise/omniauth_callbacks_controller.rb +2 -2
  12. data/app/controllers/devise/passwords_controller.rb +5 -3
  13. data/app/controllers/devise/registrations_controller.rb +26 -10
  14. data/app/controllers/devise/sessions_controller.rb +39 -14
  15. data/app/controllers/devise/unlocks_controller.rb +4 -2
  16. data/app/controllers/devise_controller.rb +6 -6
  17. data/app/helpers/devise_helper.rb +2 -2
  18. data/app/views/devise/confirmations/new.html.erb +2 -2
  19. data/app/views/devise/mailer/confirmation_instructions.html.erb +1 -1
  20. data/app/views/devise/mailer/reset_password_instructions.html.erb +1 -1
  21. data/app/views/devise/mailer/unlock_instructions.html.erb +1 -1
  22. data/app/views/devise/passwords/edit.html.erb +3 -3
  23. data/app/views/devise/passwords/new.html.erb +2 -2
  24. data/app/views/devise/registrations/edit.html.erb +6 -6
  25. data/app/views/devise/registrations/new.html.erb +5 -5
  26. data/app/views/devise/sessions/new.html.erb +5 -5
  27. data/app/views/devise/shared/_links.erb +1 -1
  28. data/app/views/devise/unlocks/new.html.erb +2 -2
  29. data/config/locales/en.yml +17 -16
  30. data/devise.gemspec +2 -2
  31. data/gemfiles/{Gemfile.rails-3.2.x → Gemfile.rails-3.2-stable} +8 -10
  32. data/gemfiles/Gemfile.rails-3.2-stable.lock +166 -0
  33. data/gemfiles/Gemfile.rails-4.0-stable +29 -0
  34. data/gemfiles/Gemfile.rails-4.0-stable.lock +162 -0
  35. data/gemfiles/Gemfile.rails-head +32 -0
  36. data/gemfiles/Gemfile.rails-head.lock +190 -0
  37. data/lib/devise/controllers/helpers.rb +84 -29
  38. data/lib/devise/controllers/rememberable.rb +3 -3
  39. data/lib/devise/controllers/scoped_views.rb +1 -1
  40. data/lib/devise/controllers/sign_in_out.rb +9 -10
  41. data/lib/devise/controllers/store_location.rb +56 -0
  42. data/lib/devise/controllers/url_helpers.rb +3 -1
  43. data/lib/devise/failure_app.rb +12 -10
  44. data/lib/devise/hooks/activatable.rb +5 -6
  45. data/lib/devise/hooks/csrf_cleaner.rb +3 -1
  46. data/lib/devise/hooks/lockable.rb +1 -1
  47. data/lib/devise/hooks/proxy.rb +2 -2
  48. data/lib/devise/hooks/rememberable.rb +2 -2
  49. data/lib/devise/hooks/timeoutable.rb +10 -3
  50. data/lib/devise/hooks/trackable.rb +1 -1
  51. data/lib/devise/mailers/helpers.rb +8 -8
  52. data/lib/devise/mapping.rb +4 -1
  53. data/lib/devise/models/authenticatable.rb +5 -5
  54. data/lib/devise/models/confirmable.rb +14 -14
  55. data/lib/devise/models/database_authenticatable.rb +18 -5
  56. data/lib/devise/models/lockable.rb +14 -11
  57. data/lib/devise/models/omniauthable.rb +1 -1
  58. data/lib/devise/models/recoverable.rb +23 -7
  59. data/lib/devise/models/rememberable.rb +6 -6
  60. data/lib/devise/models/timeoutable.rb +2 -2
  61. data/lib/devise/models/trackable.rb +5 -2
  62. data/lib/devise/models/validatable.rb +6 -6
  63. data/lib/devise/modules.rb +10 -10
  64. data/lib/devise/omniauth/url_helpers.rb +2 -2
  65. data/lib/devise/orm/active_record.rb +1 -1
  66. data/lib/devise/orm/mongoid.rb +1 -1
  67. data/lib/devise/rails/routes.rb +107 -78
  68. data/lib/devise/rails.rb +7 -1
  69. data/lib/devise/strategies/authenticatable.rb +11 -4
  70. data/lib/devise/strategies/base.rb +1 -1
  71. data/lib/devise/strategies/database_authenticatable.rb +7 -4
  72. data/lib/devise/test_helpers.rb +2 -2
  73. data/lib/devise/time_inflector.rb +2 -2
  74. data/lib/devise/version.rb +1 -1
  75. data/lib/devise.rb +15 -10
  76. data/lib/generators/active_record/devise_generator.rb +27 -10
  77. data/lib/generators/active_record/templates/migration.rb +4 -4
  78. data/lib/generators/active_record/templates/migration_existing.rb +4 -4
  79. data/lib/generators/devise/devise_generator.rb +5 -3
  80. data/lib/generators/devise/install_generator.rb +5 -0
  81. data/lib/generators/devise/views_generator.rb +31 -18
  82. data/lib/generators/mongoid/devise_generator.rb +20 -19
  83. data/lib/generators/templates/README +4 -4
  84. data/lib/generators/templates/devise.rb +20 -11
  85. data/lib/generators/templates/markerb/confirmation_instructions.markerb +1 -1
  86. data/lib/generators/templates/markerb/reset_password_instructions.markerb +1 -1
  87. data/lib/generators/templates/markerb/unlock_instructions.markerb +1 -1
  88. data/lib/generators/templates/simple_form_for/confirmations/new.html.erb +2 -2
  89. data/lib/generators/templates/simple_form_for/passwords/edit.html.erb +4 -4
  90. data/lib/generators/templates/simple_form_for/passwords/new.html.erb +2 -2
  91. data/lib/generators/templates/simple_form_for/registrations/edit.html.erb +6 -6
  92. data/lib/generators/templates/simple_form_for/registrations/new.html.erb +4 -4
  93. data/lib/generators/templates/simple_form_for/sessions/new.html.erb +4 -4
  94. data/lib/generators/templates/simple_form_for/unlocks/new.html.erb +2 -2
  95. data/script/cached-bundle +49 -0
  96. data/script/s3-put +71 -0
  97. data/test/controllers/custom_registrations_controller_test.rb +35 -0
  98. data/test/controllers/helpers_test.rb +89 -31
  99. data/test/controllers/internal_helpers_test.rb +11 -8
  100. data/test/controllers/passwords_controller_test.rb +1 -1
  101. data/test/controllers/sessions_controller_test.rb +29 -25
  102. data/test/controllers/url_helpers_test.rb +4 -4
  103. data/test/delegator_test.rb +1 -1
  104. data/test/devise_test.rb +21 -8
  105. data/test/failure_app_test.rb +61 -25
  106. data/test/generators/active_record_generator_test.rb +10 -4
  107. data/test/generators/devise_generator_test.rb +2 -2
  108. data/test/generators/mongoid_generator_test.rb +3 -3
  109. data/test/generators/views_generator_test.rb +30 -1
  110. data/test/helpers/devise_helper_test.rb +14 -13
  111. data/test/integration/authenticatable_test.rb +61 -45
  112. data/test/integration/confirmable_test.rb +95 -55
  113. data/test/integration/database_authenticatable_test.rb +16 -16
  114. data/test/integration/http_authenticatable_test.rb +12 -12
  115. data/test/integration/lockable_test.rb +43 -43
  116. data/test/integration/omniauthable_test.rb +3 -3
  117. data/test/integration/recoverable_test.rb +53 -53
  118. data/test/integration/registerable_test.rb +90 -80
  119. data/test/integration/rememberable_test.rb +15 -15
  120. data/test/integration/timeoutable_test.rb +27 -16
  121. data/test/integration/trackable_test.rb +4 -4
  122. data/test/mailers/confirmation_instructions_test.rb +7 -7
  123. data/test/mailers/reset_password_instructions_test.rb +6 -6
  124. data/test/mailers/unlock_instructions_test.rb +5 -5
  125. data/test/mapping_test.rb +3 -3
  126. data/test/models/authenticatable_test.rb +3 -3
  127. data/test/models/confirmable_test.rb +32 -32
  128. data/test/models/database_authenticatable_test.rb +32 -27
  129. data/test/models/lockable_test.rb +57 -33
  130. data/test/models/recoverable_test.rb +34 -22
  131. data/test/models/rememberable_test.rb +29 -14
  132. data/test/models/serializable_test.rb +8 -8
  133. data/test/models/timeoutable_test.rb +1 -1
  134. data/test/models/trackable_test.rb +28 -0
  135. data/test/models/validatable_test.rb +13 -13
  136. data/test/omniauth/config_test.rb +4 -4
  137. data/test/omniauth/url_helpers_test.rb +3 -3
  138. data/test/orm/mongoid.rb +1 -1
  139. data/test/parameter_sanitizer_test.rb +1 -1
  140. data/test/rails_app/app/active_record/shim.rb +1 -1
  141. data/test/rails_app/app/active_record/user_on_engine.rb +7 -0
  142. data/test/rails_app/app/active_record/user_on_main_app.rb +7 -0
  143. data/test/rails_app/app/controllers/admins/sessions_controller.rb +1 -1
  144. data/test/rails_app/app/controllers/admins_controller.rb +1 -1
  145. data/test/rails_app/app/controllers/application_controller.rb +5 -2
  146. data/test/rails_app/app/controllers/application_with_fake_engine.rb +30 -0
  147. data/test/rails_app/app/controllers/custom/registrations_controller.rb +21 -0
  148. data/test/rails_app/app/controllers/home_controller.rb +1 -1
  149. data/test/rails_app/app/controllers/publisher/registrations_controller.rb +1 -1
  150. data/test/rails_app/app/controllers/publisher/sessions_controller.rb +1 -1
  151. data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +4 -4
  152. data/test/rails_app/app/controllers/users_controller.rb +6 -6
  153. data/test/rails_app/app/mailers/users/mailer.rb +4 -4
  154. data/test/rails_app/app/mongoid/admin.rb +11 -11
  155. data/test/rails_app/app/mongoid/shim.rb +2 -2
  156. data/test/rails_app/app/mongoid/user.rb +19 -19
  157. data/test/rails_app/app/mongoid/user_on_engine.rb +39 -0
  158. data/test/rails_app/app/mongoid/user_on_main_app.rb +39 -0
  159. data/test/rails_app/app/views/admins/sessions/new.html.erb +1 -1
  160. data/test/rails_app/app/views/home/admin_dashboard.html.erb +1 -1
  161. data/test/rails_app/app/views/home/index.html.erb +1 -1
  162. data/test/rails_app/app/views/home/join.html.erb +1 -1
  163. data/test/rails_app/app/views/home/user_dashboard.html.erb +1 -1
  164. data/test/rails_app/app/views/layouts/application.html.erb +1 -1
  165. data/test/rails_app/config/application.rb +2 -2
  166. data/test/rails_app/config/boot.rb +7 -1
  167. data/test/rails_app/config/environments/development.rb +0 -4
  168. data/test/rails_app/config/environments/production.rb +0 -4
  169. data/test/rails_app/config/initializers/devise.rb +7 -5
  170. data/test/rails_app/config/initializers/secret_token.rb +1 -1
  171. data/test/rails_app/config/routes.rb +60 -42
  172. data/test/rails_app/db/migrate/20100401102949_create_tables.rb +7 -7
  173. data/test/rails_app/db/schema.rb +21 -17
  174. data/test/rails_app/lib/shared_admin.rb +4 -4
  175. data/test/rails_app/lib/shared_user.rb +1 -1
  176. data/test/rails_app/lib/shared_user_without_omniauth.rb +13 -0
  177. data/test/routes_test.rb +72 -58
  178. data/test/support/action_controller/record_identifier.rb +10 -0
  179. data/test/support/assertions.rb +2 -3
  180. data/test/support/helpers.rb +4 -4
  181. data/test/support/integration.rb +14 -14
  182. data/test/support/mongoid.yml +6 -0
  183. data/test/test_helper.rb +2 -7
  184. data/test/test_helpers_test.rb +25 -35
  185. data/test/test_models.rb +12 -5
  186. metadata +53 -38
  187. data/gemfiles/Gemfile.rails-3.2.x.lock +0 -159
@@ -0,0 +1,162 @@
1
+ GIT
2
+ remote: git://github.com/rails/rails.git
3
+ revision: 6d95e04c6968fb7597ea5dbd08b31f271fb87c9c
4
+ branch: 4-0-stable
5
+ specs:
6
+ actionmailer (4.0.8)
7
+ actionpack (= 4.0.8)
8
+ mail (~> 2.5, >= 2.5.4)
9
+ actionpack (4.0.8)
10
+ activesupport (= 4.0.8)
11
+ builder (~> 3.1.0)
12
+ erubis (~> 2.7.0)
13
+ rack (~> 1.5.2)
14
+ rack-test (~> 0.6.2)
15
+ activemodel (4.0.8)
16
+ activesupport (= 4.0.8)
17
+ builder (~> 3.1.0)
18
+ activerecord (4.0.8)
19
+ activemodel (= 4.0.8)
20
+ activerecord-deprecated_finders (~> 1.0.2)
21
+ activesupport (= 4.0.8)
22
+ arel (~> 4.0.0)
23
+ activesupport (4.0.8)
24
+ i18n (~> 0.6, >= 0.6.9)
25
+ minitest (~> 4.2)
26
+ multi_json (~> 1.3)
27
+ thread_safe (~> 0.1)
28
+ tzinfo (~> 0.3.37)
29
+ rails (4.0.8)
30
+ actionmailer (= 4.0.8)
31
+ actionpack (= 4.0.8)
32
+ activerecord (= 4.0.8)
33
+ activesupport (= 4.0.8)
34
+ bundler (>= 1.3.0, < 2.0)
35
+ railties (= 4.0.8)
36
+ sprockets-rails (~> 2.0)
37
+ railties (4.0.8)
38
+ actionpack (= 4.0.8)
39
+ activesupport (= 4.0.8)
40
+ rake (>= 0.8.7)
41
+ thor (>= 0.18.1, < 2.0)
42
+
43
+ PATH
44
+ remote: ..
45
+ specs:
46
+ devise (3.3.0)
47
+ bcrypt (~> 3.0)
48
+ orm_adapter (~> 0.1)
49
+ railties (>= 3.2.6, < 5)
50
+ thread_safe (~> 0.1)
51
+ warden (~> 1.2.3)
52
+
53
+ GEM
54
+ remote: https://rubygems.org/
55
+ specs:
56
+ activerecord-deprecated_finders (1.0.3)
57
+ arel (4.0.2)
58
+ bcrypt (3.1.7)
59
+ bson (2.3.0)
60
+ builder (3.1.4)
61
+ connection_pool (2.0.0)
62
+ erubis (2.7.0)
63
+ faraday (0.9.0)
64
+ multipart-post (>= 1.2, < 3)
65
+ hashie (3.2.0)
66
+ hike (1.2.3)
67
+ i18n (0.6.11)
68
+ json (1.8.1)
69
+ jwt (1.0.0)
70
+ mail (2.6.1)
71
+ mime-types (>= 1.16, < 3)
72
+ metaclass (0.0.4)
73
+ mime-types (2.3)
74
+ mini_portile (0.6.0)
75
+ minitest (4.7.5)
76
+ mocha (1.1.0)
77
+ metaclass (~> 0.0.1)
78
+ mongoid (4.0.0)
79
+ activemodel (~> 4.0)
80
+ moped (~> 2.0.0)
81
+ origin (~> 2.1)
82
+ tzinfo (>= 0.3.37)
83
+ moped (2.0.0)
84
+ bson (~> 2.2)
85
+ connection_pool (~> 2.0)
86
+ optionable (~> 0.2.0)
87
+ multi_json (1.10.1)
88
+ multi_xml (0.5.5)
89
+ multipart-post (2.0.0)
90
+ nokogiri (1.6.3.1)
91
+ mini_portile (= 0.6.0)
92
+ oauth2 (0.9.4)
93
+ faraday (>= 0.8, < 0.10)
94
+ jwt (~> 1.0)
95
+ multi_json (~> 1.3)
96
+ multi_xml (~> 0.5)
97
+ rack (~> 1.2)
98
+ omniauth (1.2.2)
99
+ hashie (>= 1.2, < 4)
100
+ rack (~> 1.0)
101
+ omniauth-facebook (1.6.0)
102
+ omniauth-oauth2 (~> 1.1)
103
+ omniauth-oauth2 (1.1.2)
104
+ faraday (>= 0.8, < 0.10)
105
+ multi_json (~> 1.3)
106
+ oauth2 (~> 0.9.3)
107
+ omniauth (~> 1.2)
108
+ omniauth-openid (1.0.1)
109
+ omniauth (~> 1.0)
110
+ rack-openid (~> 1.3.1)
111
+ optionable (0.2.0)
112
+ origin (2.1.1)
113
+ orm_adapter (0.5.0)
114
+ rack (1.5.2)
115
+ rack-openid (1.3.1)
116
+ rack (>= 1.1.0)
117
+ ruby-openid (>= 2.1.8)
118
+ rack-test (0.6.2)
119
+ rack (>= 1.0)
120
+ rake (10.3.2)
121
+ rdoc (4.1.1)
122
+ json (~> 1.4)
123
+ ruby-openid (2.5.0)
124
+ sprockets (2.12.1)
125
+ hike (~> 1.2)
126
+ multi_json (~> 1.0)
127
+ rack (~> 1.0)
128
+ tilt (~> 1.1, != 1.3.0)
129
+ sprockets-rails (2.1.3)
130
+ actionpack (>= 3.0)
131
+ activesupport (>= 3.0)
132
+ sprockets (~> 2.8)
133
+ sqlite3 (1.3.9)
134
+ thor (0.19.1)
135
+ thread_safe (0.3.4)
136
+ tilt (1.4.1)
137
+ tzinfo (0.3.40)
138
+ warden (1.2.3)
139
+ rack (>= 1.0)
140
+ webrat (0.7.3)
141
+ nokogiri (>= 1.2.0)
142
+ rack (>= 1.0)
143
+ rack-test (>= 0.5.3)
144
+
145
+ PLATFORMS
146
+ ruby
147
+
148
+ DEPENDENCIES
149
+ activerecord-jdbc-adapter
150
+ activerecord-jdbcsqlite3-adapter
151
+ devise!
152
+ jruby-openssl
153
+ mocha (~> 1.1)
154
+ mongoid (~> 4.0.0)
155
+ omniauth (~> 1.2.0)
156
+ omniauth-facebook
157
+ omniauth-oauth2 (~> 1.1.0)
158
+ omniauth-openid (~> 1.0.1)
159
+ rails!
160
+ rdoc
161
+ sqlite3
162
+ webrat (= 0.7.3)
@@ -0,0 +1,32 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec path: '..'
4
+
5
+ gem "rails", github: "rails/rails"
6
+ gem "arel", github: "rails/arel"
7
+ gem "rack", github: "rack/rack"
8
+ gem "i18n", github: "svenfuchs/i18n"
9
+ gem "omniauth", "~> 1.2.0"
10
+ gem "omniauth-oauth2", "~> 1.1.0"
11
+ gem "rdoc"
12
+
13
+ group :test do
14
+ gem "omniauth-facebook"
15
+ gem "omniauth-openid", "~> 1.0.1"
16
+ gem "webrat", "0.7.3", require: false
17
+ gem "mocha", "~> 1.1", require: false
18
+ end
19
+
20
+ platforms :jruby do
21
+ gem "activerecord-jdbc-adapter"
22
+ gem "activerecord-jdbcsqlite3-adapter"
23
+ gem "jruby-openssl"
24
+ end
25
+
26
+ platforms :ruby do
27
+ gem "sqlite3"
28
+ end
29
+
30
+ group :mongoid do
31
+ gem "mongoid", github: "mongoid/mongoid", branch: "master"
32
+ end
@@ -0,0 +1,190 @@
1
+ GIT
2
+ remote: git://github.com/mongoid/mongoid.git
3
+ revision: 8cb17e9839973b76295cf87189e91a5ffcc03ab0
4
+ branch: master
5
+ specs:
6
+ mongoid (4.0.0)
7
+ activemodel (~> 4.0)
8
+ moped (~> 2.0.0)
9
+ origin (~> 2.1)
10
+ tzinfo (>= 0.3.37)
11
+
12
+ GIT
13
+ remote: git://github.com/rack/rack.git
14
+ revision: 92811eec6e86cb4dba52b3969c4dd66e639df158
15
+ specs:
16
+ rack (1.6.0.alpha)
17
+
18
+ GIT
19
+ remote: git://github.com/rails/arel.git
20
+ revision: 66cee768bc163537087037a583f60639eae49fc3
21
+ specs:
22
+ arel (6.0.0.20140505020427)
23
+
24
+ GIT
25
+ remote: git://github.com/rails/rails.git
26
+ revision: d5be08347fb7ff758572775ec93247a3ca886004
27
+ specs:
28
+ actionmailer (4.2.0.alpha)
29
+ actionpack (= 4.2.0.alpha)
30
+ actionview (= 4.2.0.alpha)
31
+ mail (~> 2.5, >= 2.5.4)
32
+ actionpack (4.2.0.alpha)
33
+ actionview (= 4.2.0.alpha)
34
+ activesupport (= 4.2.0.alpha)
35
+ rack (~> 1.6.0.alpha)
36
+ rack-test (~> 0.6.2)
37
+ actionview (4.2.0.alpha)
38
+ activesupport (= 4.2.0.alpha)
39
+ builder (~> 3.1)
40
+ erubis (~> 2.7.0)
41
+ activemodel (4.2.0.alpha)
42
+ activesupport (= 4.2.0.alpha)
43
+ builder (~> 3.1)
44
+ activerecord (4.2.0.alpha)
45
+ activemodel (= 4.2.0.alpha)
46
+ activesupport (= 4.2.0.alpha)
47
+ arel (~> 6.0.0)
48
+ activesupport (4.2.0.alpha)
49
+ i18n (>= 0.7.0.dev, < 0.8)
50
+ json (~> 1.7, >= 1.7.7)
51
+ minitest (~> 5.1)
52
+ thread_safe (~> 0.1)
53
+ tzinfo (~> 1.1)
54
+ rails (4.2.0.alpha)
55
+ actionmailer (= 4.2.0.alpha)
56
+ actionpack (= 4.2.0.alpha)
57
+ actionview (= 4.2.0.alpha)
58
+ activemodel (= 4.2.0.alpha)
59
+ activerecord (= 4.2.0.alpha)
60
+ activesupport (= 4.2.0.alpha)
61
+ bundler (>= 1.3.0, < 2.0)
62
+ railties (= 4.2.0.alpha)
63
+ sprockets-rails (~> 2.1)
64
+ railties (4.2.0.alpha)
65
+ actionpack (= 4.2.0.alpha)
66
+ activesupport (= 4.2.0.alpha)
67
+ rake (>= 0.8.7)
68
+ thor (>= 0.18.1, < 2.0)
69
+
70
+ GIT
71
+ remote: git://github.com/svenfuchs/i18n.git
72
+ revision: cb679b8cdbab675703a3f88de4d48a48f7b50e06
73
+ specs:
74
+ i18n (0.7.0.dev)
75
+
76
+ PATH
77
+ remote: ..
78
+ specs:
79
+ devise (3.3.0)
80
+ bcrypt (~> 3.0)
81
+ orm_adapter (~> 0.1)
82
+ railties (>= 3.2.6, < 5)
83
+ thread_safe (~> 0.1)
84
+ warden (~> 1.2.3)
85
+
86
+ GEM
87
+ remote: https://rubygems.org/
88
+ specs:
89
+ bcrypt (3.1.7)
90
+ bson (2.3.0)
91
+ builder (3.2.2)
92
+ connection_pool (2.0.0)
93
+ erubis (2.7.0)
94
+ faraday (0.9.0)
95
+ multipart-post (>= 1.2, < 3)
96
+ hashie (3.2.0)
97
+ hike (1.2.3)
98
+ json (1.8.1)
99
+ jwt (1.0.0)
100
+ mail (2.6.1)
101
+ mime-types (>= 1.16, < 3)
102
+ metaclass (0.0.4)
103
+ mime-types (2.3)
104
+ mini_portile (0.6.0)
105
+ minitest (5.4.0)
106
+ mocha (1.1.0)
107
+ metaclass (~> 0.0.1)
108
+ moped (2.0.0)
109
+ bson (~> 2.2)
110
+ connection_pool (~> 2.0)
111
+ optionable (~> 0.2.0)
112
+ multi_json (1.10.1)
113
+ multi_xml (0.5.5)
114
+ multipart-post (2.0.0)
115
+ nokogiri (1.6.3.1)
116
+ mini_portile (= 0.6.0)
117
+ oauth2 (0.9.4)
118
+ faraday (>= 0.8, < 0.10)
119
+ jwt (~> 1.0)
120
+ multi_json (~> 1.3)
121
+ multi_xml (~> 0.5)
122
+ rack (~> 1.2)
123
+ omniauth (1.2.2)
124
+ hashie (>= 1.2, < 4)
125
+ rack (~> 1.0)
126
+ omniauth-facebook (1.6.0)
127
+ omniauth-oauth2 (~> 1.1)
128
+ omniauth-oauth2 (1.1.2)
129
+ faraday (>= 0.8, < 0.10)
130
+ multi_json (~> 1.3)
131
+ oauth2 (~> 0.9.3)
132
+ omniauth (~> 1.2)
133
+ omniauth-openid (1.0.1)
134
+ omniauth (~> 1.0)
135
+ rack-openid (~> 1.3.1)
136
+ optionable (0.2.0)
137
+ origin (2.1.1)
138
+ orm_adapter (0.5.0)
139
+ rack-openid (1.3.1)
140
+ rack (>= 1.1.0)
141
+ ruby-openid (>= 2.1.8)
142
+ rack-test (0.6.2)
143
+ rack (>= 1.0)
144
+ rake (10.3.2)
145
+ rdoc (4.1.1)
146
+ json (~> 1.4)
147
+ ruby-openid (2.5.0)
148
+ sprockets (2.12.1)
149
+ hike (~> 1.2)
150
+ multi_json (~> 1.0)
151
+ rack (~> 1.0)
152
+ tilt (~> 1.1, != 1.3.0)
153
+ sprockets-rails (2.1.3)
154
+ actionpack (>= 3.0)
155
+ activesupport (>= 3.0)
156
+ sprockets (~> 2.8)
157
+ sqlite3 (1.3.9)
158
+ thor (0.19.1)
159
+ thread_safe (0.3.4)
160
+ tilt (1.4.1)
161
+ tzinfo (1.2.1)
162
+ thread_safe (~> 0.1)
163
+ warden (1.2.3)
164
+ rack (>= 1.0)
165
+ webrat (0.7.3)
166
+ nokogiri (>= 1.2.0)
167
+ rack (>= 1.0)
168
+ rack-test (>= 0.5.3)
169
+
170
+ PLATFORMS
171
+ ruby
172
+
173
+ DEPENDENCIES
174
+ activerecord-jdbc-adapter
175
+ activerecord-jdbcsqlite3-adapter
176
+ arel!
177
+ devise!
178
+ i18n!
179
+ jruby-openssl
180
+ mocha (~> 1.1)
181
+ mongoid!
182
+ omniauth (~> 1.2.0)
183
+ omniauth-facebook
184
+ omniauth-oauth2 (~> 1.1.0)
185
+ omniauth-openid (~> 1.0.1)
186
+ rack!
187
+ rails!
188
+ rdoc
189
+ sqlite3
190
+ webrat (= 0.7.3)
@@ -4,12 +4,75 @@ module Devise
4
4
  module Helpers
5
5
  extend ActiveSupport::Concern
6
6
  include Devise::Controllers::SignInOut
7
+ include Devise::Controllers::StoreLocation
7
8
 
8
9
  included do
9
10
  helper_method :warden, :signed_in?, :devise_controller?
10
11
  end
11
12
 
12
13
  module ClassMethods
14
+ # Define authentication filters and accessor helpers for a group of mappings.
15
+ # These methods are useful when you are working with multiple mappings that
16
+ # share some functionality. They are pretty much the same as the ones
17
+ # defined for normal mappings.
18
+ #
19
+ # Example:
20
+ #
21
+ # inside BlogsController (or any other controller, it doesn't matter which):
22
+ # devise_group :blogger, contains: [:user, :admin]
23
+ #
24
+ # Generated methods:
25
+ # authenticate_blogger! # Redirects unless user or admin are signed in
26
+ # blogger_signed_in? # Checks whether there is either a user or an admin signed in
27
+ # current_blogger # Currently signed in user or admin
28
+ # current_bloggers # Currently signed in user and admin
29
+ #
30
+ # Use:
31
+ # before_filter :authenticate_blogger! # Redirects unless either a user or an admin are authenticated
32
+ # before_filter ->{ authenticate_blogger! :admin } # Redirects to the admin login page
33
+ # current_blogger :user # Preferably returns a User if one is signed in
34
+ #
35
+ def devise_group(group_name, opts={})
36
+ mappings = "[#{ opts[:contains].map { |m| ":#{m}" }.join(',') }]"
37
+
38
+ class_eval <<-METHODS, __FILE__, __LINE__ + 1
39
+ def authenticate_#{group_name}!(favourite=nil, opts={})
40
+ unless #{group_name}_signed_in?
41
+ mappings = #{mappings}
42
+ mappings.unshift mappings.delete(favourite.to_sym) if favourite
43
+ mappings.each do |mapping|
44
+ opts[:scope] = mapping
45
+ warden.authenticate!(opts) if !devise_controller? || opts.delete(:force)
46
+ end
47
+ end
48
+ end
49
+
50
+ def #{group_name}_signed_in?
51
+ #{mappings}.any? do |mapping|
52
+ warden.authenticate?(scope: mapping)
53
+ end
54
+ end
55
+
56
+ def current_#{group_name}(favourite=nil)
57
+ mappings = #{mappings}
58
+ mappings.unshift mappings.delete(favourite.to_sym) if favourite
59
+ mappings.each do |mapping|
60
+ current = warden.authenticate(scope: mapping)
61
+ return current if current
62
+ end
63
+ nil
64
+ end
65
+
66
+ def current_#{group_name.to_s.pluralize}
67
+ #{mappings}.map do |mapping|
68
+ warden.authenticate(scope: mapping)
69
+ end.compact
70
+ end
71
+
72
+ helper_method "current_#{group_name}", "current_#{group_name.to_s.pluralize}", "#{group_name}_signed_in?"
73
+ METHODS
74
+ end
75
+
13
76
  def log_process_action(payload)
14
77
  payload[:status] ||= 401 unless payload[:exception]
15
78
  super
@@ -54,7 +117,7 @@ module Devise
54
117
  end
55
118
 
56
119
  def current_#{mapping}
57
- @current_#{mapping} ||= warden.authenticate(:scope => :#{mapping})
120
+ @current_#{mapping} ||= warden.authenticate(scope: :#{mapping})
58
121
  end
59
122
 
60
123
  def #{mapping}_session
@@ -76,9 +139,9 @@ module Devise
76
139
  # the controllers defined inside devise. Useful if you want to apply a before
77
140
  # filter to all controllers, except the ones in devise:
78
141
  #
79
- # before_filter :my_filter, :unless => :devise_controller?
142
+ # before_filter :my_filter, unless: :devise_controller?
80
143
  def devise_controller?
81
- is_a?(DeviseController)
144
+ is_a?(::DeviseController)
82
145
  end
83
146
 
84
147
  # Setup a param sanitizer to filter parameters using strong_parameters. See
@@ -97,30 +160,20 @@ module Devise
97
160
  request.env["devise.allow_params_authentication"] = true
98
161
  end
99
162
 
100
- # Returns and delete (if it's navigational format) the url stored in the session for
101
- # the given scope. Useful for giving redirect backs after sign up:
102
- #
103
- # Example:
104
- #
105
- # redirect_to stored_location_for(:user) || root_path
106
- #
107
- def stored_location_for(resource_or_scope)
108
- scope = Devise::Mapping.find_scope!(resource_or_scope)
109
-
110
- if is_navigational_format?
111
- session.delete("#{scope}_return_to")
112
- else
113
- session["#{scope}_return_to"]
114
- end
115
- end
116
-
117
- # The scope root url to be used when he's signed in. By default, it first
163
+ # The scope root url to be used when they're signed in. By default, it first
118
164
  # tries to find a resource_root_path, otherwise it uses the root_path.
119
165
  def signed_in_root_path(resource_or_scope)
120
166
  scope = Devise::Mapping.find_scope!(resource_or_scope)
167
+ router_name = Devise.mappings[scope].router_name
168
+
121
169
  home_path = "#{scope}_root_path"
122
- if respond_to?(home_path, true)
123
- send(home_path)
170
+
171
+ context = router_name ? send(router_name) : self
172
+
173
+ if context.respond_to?(home_path, true)
174
+ context.send(home_path)
175
+ elsif context.respond_to?(:root_path)
176
+ context.root_path
124
177
  elsif respond_to?(:root_path)
125
178
  root_path
126
179
  else
@@ -137,10 +190,10 @@ module Devise
137
190
  # root path. For a user scope, you can define the default url in
138
191
  # the following way:
139
192
  #
140
- # map.user_root '/users', :controller => 'users' # creates user_root_path
193
+ # map.user_root '/users', controller: 'users' # creates user_root_path
141
194
  #
142
195
  # map.namespace :user do |user|
143
- # user.root :controller => 'users' # creates user_root_path
196
+ # user.root controller: 'users' # creates user_root_path
144
197
  # end
145
198
  #
146
199
  # If the resource root path is not defined, root_path is used. However,
@@ -166,7 +219,10 @@ module Devise
166
219
  #
167
220
  # By default it is the root_path.
168
221
  def after_sign_out_path_for(resource_or_scope)
169
- respond_to?(:root_path) ? root_path : "/"
222
+ scope = Devise::Mapping.find_scope!(resource_or_scope)
223
+ router_name = Devise.mappings[scope].router_name
224
+ context = router_name ? send(router_name) : self
225
+ context.respond_to?(:root_path) ? context.root_path : "/"
170
226
  end
171
227
 
172
228
  # Sign in a user and tries to redirect first to the stored location and
@@ -192,10 +248,9 @@ module Devise
192
248
  # Overwrite Rails' handle unverified request to sign out all scopes,
193
249
  # clear run strategies and remove cached variables.
194
250
  def handle_unverified_request
195
- sign_out_all_scopes(false)
251
+ super # call the default behaviour which resets/nullifies/raises
196
252
  request.env["devise.skip_storage"] = true
197
- expire_data_after_sign_out!
198
- super # call the default behaviour which resets the session
253
+ sign_out_all_scopes(false)
199
254
  end
200
255
 
201
256
  def request_format
@@ -31,11 +31,11 @@ module Devise
31
31
  end
32
32
 
33
33
  def remember_cookie_values(resource)
34
- options = { :httponly => true }
34
+ options = { httponly: true }
35
35
  options.merge!(forget_cookie_values(resource))
36
36
  options.merge!(
37
- :value => resource.class.serialize_into_cookie(resource),
38
- :expires => resource.remember_expires_at
37
+ value: resource.class.serialize_into_cookie(resource),
38
+ expires: resource.remember_expires_at
39
39
  )
40
40
  end
41
41
 
@@ -14,4 +14,4 @@ module Devise
14
14
  end
15
15
  end
16
16
  end
17
- end
17
+ end
@@ -7,7 +7,7 @@ module Devise
7
7
  # true if any scope is signed in. Does not run authentication hooks.
8
8
  def signed_in?(scope=nil)
9
9
  [ scope || Devise.mappings.keys ].flatten.any? do |_scope|
10
- warden.authenticate?(:scope => _scope)
10
+ warden.authenticate?(scope: _scope)
11
11
  end
12
12
  end
13
13
 
@@ -23,9 +23,9 @@ module Devise
23
23
  #
24
24
  # sign_in :user, @user # sign_in(scope, resource)
25
25
  # sign_in @user # sign_in(resource)
26
- # sign_in @user, :event => :authentication # sign_in(resource, options)
27
- # sign_in @user, :store => false # sign_in(resource, options)
28
- # sign_in @user, :bypass => true # sign_in(resource, options)
26
+ # sign_in @user, event: :authentication # sign_in(resource, options)
27
+ # sign_in @user, store: false # sign_in(resource, options)
28
+ # sign_in @user, bypass: true # sign_in(resource, options)
29
29
  #
30
30
  def sign_in(resource_or_scope, *args)
31
31
  options = args.extract_options!
@@ -40,7 +40,7 @@ module Devise
40
40
  # Do nothing. User already signed in and we are not forcing it.
41
41
  true
42
42
  else
43
- warden.set_user(resource, options.merge!(:scope => scope))
43
+ warden.set_user(resource, options.merge!(scope: scope))
44
44
  end
45
45
  end
46
46
 
@@ -56,11 +56,11 @@ module Devise
56
56
  def sign_out(resource_or_scope=nil)
57
57
  return sign_out_all_scopes unless resource_or_scope
58
58
  scope = Devise::Mapping.find_scope!(resource_or_scope)
59
- user = warden.user(:scope => scope, :run_callbacks => false) # If there is no user
59
+ user = warden.user(scope: scope, run_callbacks: false) # If there is no user
60
60
 
61
61
  warden.raw_session.inspect # Without this inspect here. The session does not clear.
62
62
  warden.logout(scope)
63
- warden.clear_strategies_cache!(:scope => scope)
63
+ warden.clear_strategies_cache!(scope: scope)
64
64
  instance_variable_set(:"@current_#{scope}", nil)
65
65
 
66
66
  !!user
@@ -70,9 +70,8 @@ module Devise
70
70
  # in one click. This signs out ALL scopes in warden. Returns true if there was at least one logout
71
71
  # and false if there was no user logged in on all scopes.
72
72
  def sign_out_all_scopes(lock=true)
73
- users = Devise.mappings.keys.map { |s| warden.user(:scope => s, :run_callbacks => false) }
73
+ users = Devise.mappings.keys.map { |s| warden.user(scope: s, run_callbacks: false) }
74
74
 
75
- warden.raw_session.inspect
76
75
  warden.logout
77
76
  expire_data_after_sign_out!
78
77
  warden.clear_strategies_cache!
@@ -100,4 +99,4 @@ module Devise
100
99
  end
101
100
  end
102
101
  end
103
- end
102
+ end
@@ -0,0 +1,56 @@
1
+ require "uri"
2
+
3
+ module Devise
4
+ module Controllers
5
+ # Provide the ability to store a location.
6
+ # Used to redirect back to a desired path after sign in.
7
+ # Included by default in all controllers.
8
+ module StoreLocation
9
+ # Returns and delete (if it's navigational format) the url stored in the session for
10
+ # the given scope. Useful for giving redirect backs after sign up:
11
+ #
12
+ # Example:
13
+ #
14
+ # redirect_to stored_location_for(:user) || root_path
15
+ #
16
+ def stored_location_for(resource_or_scope)
17
+ session_key = stored_location_key_for(resource_or_scope)
18
+
19
+ if is_navigational_format?
20
+ session.delete(session_key)
21
+ else
22
+ session[session_key]
23
+ end
24
+ end
25
+
26
+ # Stores the provided location to redirect the user after signing in.
27
+ # Useful in combination with the `stored_location_for` helper.
28
+ #
29
+ # Example:
30
+ #
31
+ # store_location_for(:user, dashboard_path)
32
+ # redirect_to user_omniauth_authorize_path(:facebook)
33
+ #
34
+ def store_location_for(resource_or_scope, location)
35
+ session_key = stored_location_key_for(resource_or_scope)
36
+ uri = parse_uri(location)
37
+ if uri
38
+ session[session_key] = [uri.path.sub(/\A\/+/, '/'), uri.query].compact.join('?')
39
+ end
40
+ end
41
+
42
+ private
43
+
44
+ def parse_uri(location)
45
+ location && URI.parse(location)
46
+ rescue URI::InvalidURIError
47
+ nil
48
+ end
49
+
50
+ def stored_location_key_for(resource_or_scope)
51
+ scope = Devise::Mapping.find_scope!(resource_or_scope)
52
+ "#{scope}_return_to"
53
+ end
54
+ end
55
+ end
56
+ end