deviseOne 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (246) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.travis.yml +38 -0
  4. data/.yardopts +9 -0
  5. data/CHANGELOG.md +1117 -0
  6. data/CONTRIBUTING.md +14 -0
  7. data/Gemfile +29 -0
  8. data/Gemfile.lock +199 -0
  9. data/MIT-LICENSE +20 -0
  10. data/README.md +529 -0
  11. data/Rakefile +35 -0
  12. data/app/controllers/devise/confirmations_controller.rb +47 -0
  13. data/app/controllers/devise/omniauth_callbacks_controller.rb +30 -0
  14. data/app/controllers/devise/passwords_controller.rb +71 -0
  15. data/app/controllers/devise/registrations_controller.rb +143 -0
  16. data/app/controllers/devise/sessions_controller.rb +166 -0
  17. data/app/controllers/devise/unlocks_controller.rb +46 -0
  18. data/app/controllers/devise_controller.rb +193 -0
  19. data/app/helpers/devise_helper.rb +25 -0
  20. data/app/mailers/devise/mailer.rb +20 -0
  21. data/app/views/devise/confirmations/new.html.erb +16 -0
  22. data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
  23. data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  24. data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  25. data/app/views/devise/passwords/edit.html.erb +25 -0
  26. data/app/views/devise/passwords/new.html.erb +16 -0
  27. data/app/views/devise/registrations/edit.html.erb +39 -0
  28. data/app/views/devise/registrations/new.html.erb +29 -0
  29. data/app/views/devise/sessions/new.html.erb +27 -0
  30. data/app/views/devise/shared/_links.html.erb +21 -0
  31. data/app/views/devise/unlocks/new.html.erb +16 -0
  32. data/config/locales/en.yml +70 -0
  33. data/devise.gemspec +33 -0
  34. data/devise.png +0 -0
  35. data/gemfiles/Gemfile.rails-3.2-stable +29 -0
  36. data/gemfiles/Gemfile.rails-3.2-stable.lock +169 -0
  37. data/gemfiles/Gemfile.rails-4.0-stable +29 -0
  38. data/gemfiles/Gemfile.rails-4.0-stable.lock +165 -0
  39. data/gemfiles/Gemfile.rails-4.1-stable +29 -0
  40. data/gemfiles/Gemfile.rails-4.1-stable.lock +170 -0
  41. data/lib/devise.rb +499 -0
  42. data/lib/devise/controllers/helpers.rb +284 -0
  43. data/lib/devise/controllers/rememberable.rb +47 -0
  44. data/lib/devise/controllers/scoped_views.rb +17 -0
  45. data/lib/devise/controllers/sign_in_out.rb +102 -0
  46. data/lib/devise/controllers/store_location.rb +58 -0
  47. data/lib/devise/controllers/url_helpers.rb +69 -0
  48. data/lib/devise/delegator.rb +16 -0
  49. data/lib/devise/failure_app.rb +212 -0
  50. data/lib/devise/hooks/activatable.rb +10 -0
  51. data/lib/devise/hooks/csrf_cleaner.rb +7 -0
  52. data/lib/devise/hooks/forgetable.rb +9 -0
  53. data/lib/devise/hooks/lockable.rb +7 -0
  54. data/lib/devise/hooks/proxy.rb +21 -0
  55. data/lib/devise/hooks/rememberable.rb +7 -0
  56. data/lib/devise/hooks/timeoutable.rb +35 -0
  57. data/lib/devise/hooks/trackable.rb +9 -0
  58. data/lib/devise/mailers/helpers.rb +90 -0
  59. data/lib/devise/mapping.rb +175 -0
  60. data/lib/devise/models.rb +119 -0
  61. data/lib/devise/models/authenticatable.rb +290 -0
  62. data/lib/devise/models/confirmable.rb +305 -0
  63. data/lib/devise/models/database_authenticatable.rb +164 -0
  64. data/lib/devise/models/lockable.rb +196 -0
  65. data/lib/devise/models/omniauthable.rb +27 -0
  66. data/lib/devise/models/recoverable.rb +157 -0
  67. data/lib/devise/models/registerable.rb +25 -0
  68. data/lib/devise/models/rememberable.rb +142 -0
  69. data/lib/devise/models/timeoutable.rb +49 -0
  70. data/lib/devise/models/trackable.rb +38 -0
  71. data/lib/devise/models/validatable.rb +66 -0
  72. data/lib/devise/modules.rb +28 -0
  73. data/lib/devise/omniauth.rb +28 -0
  74. data/lib/devise/omniauth/config.rb +45 -0
  75. data/lib/devise/omniauth/url_helpers.rb +18 -0
  76. data/lib/devise/orm/active_record.rb +3 -0
  77. data/lib/devise/orm/mongoid.rb +3 -0
  78. data/lib/devise/parameter_filter.rb +40 -0
  79. data/lib/devise/parameter_sanitizer.rb +99 -0
  80. data/lib/devise/rails.rb +56 -0
  81. data/lib/devise/rails/routes.rb +495 -0
  82. data/lib/devise/rails/warden_compat.rb +22 -0
  83. data/lib/devise/strategies/authenticatable.rb +173 -0
  84. data/lib/devise/strategies/base.rb +20 -0
  85. data/lib/devise/strategies/database_authenticatable.rb +24 -0
  86. data/lib/devise/strategies/rememberable.rb +59 -0
  87. data/lib/devise/test_helpers.rb +132 -0
  88. data/lib/devise/time_inflector.rb +14 -0
  89. data/lib/devise/token_generator.rb +70 -0
  90. data/lib/devise/version.rb +3 -0
  91. data/lib/generators/active_record/devise_generator.rb +91 -0
  92. data/lib/generators/active_record/templates/migration.rb +18 -0
  93. data/lib/generators/active_record/templates/migration_existing.rb +25 -0
  94. data/lib/generators/devise/controllers_generator.rb +44 -0
  95. data/lib/generators/devise/devise_generator.rb +26 -0
  96. data/lib/generators/devise/install_generator.rb +29 -0
  97. data/lib/generators/devise/orm_helpers.rb +51 -0
  98. data/lib/generators/devise/views_generator.rb +135 -0
  99. data/lib/generators/mongoid/devise_generator.rb +55 -0
  100. data/lib/generators/templates/README +35 -0
  101. data/lib/generators/templates/controllers/README +14 -0
  102. data/lib/generators/templates/controllers/confirmations_controller.rb +28 -0
  103. data/lib/generators/templates/controllers/omniauth_callbacks_controller.rb +28 -0
  104. data/lib/generators/templates/controllers/passwords_controller.rb +32 -0
  105. data/lib/generators/templates/controllers/registrations_controller.rb +60 -0
  106. data/lib/generators/templates/controllers/sessions_controller.rb +25 -0
  107. data/lib/generators/templates/controllers/unlocks_controller.rb +28 -0
  108. data/lib/generators/templates/devise.rb +263 -0
  109. data/lib/generators/templates/markerb/confirmation_instructions.markerb +5 -0
  110. data/lib/generators/templates/markerb/reset_password_instructions.markerb +8 -0
  111. data/lib/generators/templates/markerb/unlock_instructions.markerb +7 -0
  112. data/lib/generators/templates/simple_form_for/confirmations/new.html.erb +16 -0
  113. data/lib/generators/templates/simple_form_for/passwords/edit.html.erb +19 -0
  114. data/lib/generators/templates/simple_form_for/passwords/new.html.erb +15 -0
  115. data/lib/generators/templates/simple_form_for/registrations/edit.html.erb +27 -0
  116. data/lib/generators/templates/simple_form_for/registrations/new.html.erb +17 -0
  117. data/lib/generators/templates/simple_form_for/sessions/new.html.erb +15 -0
  118. data/lib/generators/templates/simple_form_for/unlocks/new.html.erb +16 -0
  119. data/script/cached-bundle +49 -0
  120. data/script/s3-put +71 -0
  121. data/test/controllers/custom_registrations_controller_test.rb +35 -0
  122. data/test/controllers/custom_strategy_test.rb +62 -0
  123. data/test/controllers/helpers_test.rb +316 -0
  124. data/test/controllers/internal_helpers_test.rb +129 -0
  125. data/test/controllers/load_hooks_controller_test.rb +19 -0
  126. data/test/controllers/passwords_controller_test.rb +31 -0
  127. data/test/controllers/sessions_controller_test.rb +102 -0
  128. data/test/controllers/url_helpers_test.rb +65 -0
  129. data/test/delegator_test.rb +19 -0
  130. data/test/devise_test.rb +107 -0
  131. data/test/failure_app_test.rb +275 -0
  132. data/test/generators/active_record_generator_test.rb +109 -0
  133. data/test/generators/controllers_generator_test.rb +48 -0
  134. data/test/generators/devise_generator_test.rb +39 -0
  135. data/test/generators/install_generator_test.rb +13 -0
  136. data/test/generators/mongoid_generator_test.rb +23 -0
  137. data/test/generators/views_generator_test.rb +96 -0
  138. data/test/helpers/devise_helper_test.rb +49 -0
  139. data/test/integration/authenticatable_test.rb +731 -0
  140. data/test/integration/confirmable_test.rb +324 -0
  141. data/test/integration/database_authenticatable_test.rb +94 -0
  142. data/test/integration/http_authenticatable_test.rb +105 -0
  143. data/test/integration/lockable_test.rb +239 -0
  144. data/test/integration/omniauthable_test.rb +133 -0
  145. data/test/integration/recoverable_test.rb +334 -0
  146. data/test/integration/registerable_test.rb +361 -0
  147. data/test/integration/rememberable_test.rb +176 -0
  148. data/test/integration/timeoutable_test.rb +189 -0
  149. data/test/integration/trackable_test.rb +92 -0
  150. data/test/mailers/confirmation_instructions_test.rb +115 -0
  151. data/test/mailers/reset_password_instructions_test.rb +96 -0
  152. data/test/mailers/unlock_instructions_test.rb +91 -0
  153. data/test/mapping_test.rb +128 -0
  154. data/test/models/authenticatable_test.rb +23 -0
  155. data/test/models/confirmable_test.rb +461 -0
  156. data/test/models/database_authenticatable_test.rb +249 -0
  157. data/test/models/lockable_test.rb +328 -0
  158. data/test/models/omniauthable_test.rb +7 -0
  159. data/test/models/recoverable_test.rb +205 -0
  160. data/test/models/registerable_test.rb +7 -0
  161. data/test/models/rememberable_test.rb +198 -0
  162. data/test/models/serializable_test.rb +49 -0
  163. data/test/models/timeoutable_test.rb +51 -0
  164. data/test/models/trackable_test.rb +41 -0
  165. data/test/models/validatable_test.rb +127 -0
  166. data/test/models_test.rb +144 -0
  167. data/test/omniauth/config_test.rb +57 -0
  168. data/test/omniauth/url_helpers_test.rb +54 -0
  169. data/test/orm/active_record.rb +10 -0
  170. data/test/orm/mongoid.rb +13 -0
  171. data/test/parameter_sanitizer_test.rb +81 -0
  172. data/test/rails_app/Rakefile +6 -0
  173. data/test/rails_app/app/active_record/admin.rb +6 -0
  174. data/test/rails_app/app/active_record/shim.rb +2 -0
  175. data/test/rails_app/app/active_record/user.rb +6 -0
  176. data/test/rails_app/app/active_record/user_on_engine.rb +7 -0
  177. data/test/rails_app/app/active_record/user_on_main_app.rb +7 -0
  178. data/test/rails_app/app/controllers/admins/sessions_controller.rb +6 -0
  179. data/test/rails_app/app/controllers/admins_controller.rb +11 -0
  180. data/test/rails_app/app/controllers/application_controller.rb +12 -0
  181. data/test/rails_app/app/controllers/application_with_fake_engine.rb +30 -0
  182. data/test/rails_app/app/controllers/custom/registrations_controller.rb +21 -0
  183. data/test/rails_app/app/controllers/home_controller.rb +25 -0
  184. data/test/rails_app/app/controllers/publisher/registrations_controller.rb +2 -0
  185. data/test/rails_app/app/controllers/publisher/sessions_controller.rb +2 -0
  186. data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +14 -0
  187. data/test/rails_app/app/controllers/users_controller.rb +31 -0
  188. data/test/rails_app/app/helpers/application_helper.rb +3 -0
  189. data/test/rails_app/app/mailers/users/from_proc_mailer.rb +3 -0
  190. data/test/rails_app/app/mailers/users/mailer.rb +3 -0
  191. data/test/rails_app/app/mailers/users/reply_to_mailer.rb +4 -0
  192. data/test/rails_app/app/mongoid/admin.rb +29 -0
  193. data/test/rails_app/app/mongoid/shim.rb +23 -0
  194. data/test/rails_app/app/mongoid/user.rb +39 -0
  195. data/test/rails_app/app/mongoid/user_on_engine.rb +39 -0
  196. data/test/rails_app/app/mongoid/user_on_main_app.rb +39 -0
  197. data/test/rails_app/app/views/admins/index.html.erb +1 -0
  198. data/test/rails_app/app/views/admins/sessions/new.html.erb +2 -0
  199. data/test/rails_app/app/views/home/admin_dashboard.html.erb +1 -0
  200. data/test/rails_app/app/views/home/index.html.erb +1 -0
  201. data/test/rails_app/app/views/home/join.html.erb +1 -0
  202. data/test/rails_app/app/views/home/private.html.erb +1 -0
  203. data/test/rails_app/app/views/home/user_dashboard.html.erb +1 -0
  204. data/test/rails_app/app/views/layouts/application.html.erb +24 -0
  205. data/test/rails_app/app/views/users/edit_form.html.erb +1 -0
  206. data/test/rails_app/app/views/users/index.html.erb +1 -0
  207. data/test/rails_app/app/views/users/mailer/confirmation_instructions.erb +1 -0
  208. data/test/rails_app/app/views/users/sessions/new.html.erb +1 -0
  209. data/test/rails_app/bin/bundle +3 -0
  210. data/test/rails_app/bin/rails +4 -0
  211. data/test/rails_app/bin/rake +4 -0
  212. data/test/rails_app/config.ru +4 -0
  213. data/test/rails_app/config/application.rb +40 -0
  214. data/test/rails_app/config/boot.rb +14 -0
  215. data/test/rails_app/config/database.yml +18 -0
  216. data/test/rails_app/config/environment.rb +5 -0
  217. data/test/rails_app/config/environments/development.rb +30 -0
  218. data/test/rails_app/config/environments/production.rb +80 -0
  219. data/test/rails_app/config/environments/test.rb +36 -0
  220. data/test/rails_app/config/initializers/backtrace_silencers.rb +7 -0
  221. data/test/rails_app/config/initializers/devise.rb +180 -0
  222. data/test/rails_app/config/initializers/inflections.rb +2 -0
  223. data/test/rails_app/config/initializers/secret_token.rb +8 -0
  224. data/test/rails_app/config/initializers/session_store.rb +1 -0
  225. data/test/rails_app/config/routes.rb +122 -0
  226. data/test/rails_app/db/migrate/20100401102949_create_tables.rb +71 -0
  227. data/test/rails_app/db/schema.rb +55 -0
  228. data/test/rails_app/lib/shared_admin.rb +17 -0
  229. data/test/rails_app/lib/shared_user.rb +29 -0
  230. data/test/rails_app/lib/shared_user_without_omniauth.rb +13 -0
  231. data/test/rails_app/public/404.html +26 -0
  232. data/test/rails_app/public/422.html +26 -0
  233. data/test/rails_app/public/500.html +26 -0
  234. data/test/rails_app/public/favicon.ico +0 -0
  235. data/test/routes_test.rb +264 -0
  236. data/test/support/action_controller/record_identifier.rb +10 -0
  237. data/test/support/assertions.rb +39 -0
  238. data/test/support/helpers.rb +73 -0
  239. data/test/support/integration.rb +92 -0
  240. data/test/support/locale/en.yml +8 -0
  241. data/test/support/mongoid.yml +6 -0
  242. data/test/support/webrat/integrations/rails.rb +24 -0
  243. data/test/test_helper.rb +34 -0
  244. data/test/test_helpers_test.rb +163 -0
  245. data/test/test_models.rb +33 -0
  246. metadata +531 -0
@@ -0,0 +1,14 @@
1
+ ### Please read before contributing
2
+
3
+ 1) Do not post questions in the issues tracker. If you have any questions about Devise, search the [Wiki](https://github.com/plataformatec/devise/wiki) or use the [Mailing List](https://groups.google.com/group/plataformatec-devise) or [Stack Overflow](http://stackoverflow.com/questions/tagged/devise).
4
+
5
+ 2) If you find a security bug, **DO NOT** submit an issue here. Please send an e-mail to [opensource@plataformatec.com.br](mailto:opensource@plataformatec.com.br) instead.
6
+
7
+ 3) Do a small search on the issues tracker before submitting your issue to see if it was already reported / fixed.
8
+
9
+ 4) When reporting an issue, include Rails, Devise and Warden versions. If you are getting exceptions, please include the full backtrace.
10
+
11
+ That's it! The more information you give, the easier it becomes for us to track it down and fix it.
12
+ Ideally, you should provide an application that reproduces the error or a test case to Devise's suite.
13
+
14
+ Thanks!
data/Gemfile ADDED
@@ -0,0 +1,29 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem "rails", "4.2.0.rc3"
6
+ gem "omniauth", "~> 1.2.0"
7
+ gem "omniauth-oauth2", "~> 1.1.0"
8
+ gem "rdoc"
9
+
10
+ group :test do
11
+ gem "omniauth-facebook"
12
+ gem "omniauth-openid", "~> 1.0.1"
13
+ gem "webrat", "0.7.3", require: false
14
+ gem "mocha", "~> 1.1", require: false
15
+ end
16
+
17
+ platforms :jruby do
18
+ gem "activerecord-jdbc-adapter"
19
+ gem "activerecord-jdbcsqlite3-adapter"
20
+ gem "jruby-openssl"
21
+ end
22
+
23
+ platforms :ruby do
24
+ gem "sqlite3"
25
+ end
26
+
27
+ group :mongoid do
28
+ gem "mongoid", github: "mongoid/mongoid", branch: "master"
29
+ end
@@ -0,0 +1,199 @@
1
+ GIT
2
+ remote: git://github.com/mongoid/mongoid.git
3
+ revision: 90567eab72caa136bae6efcfcf61a6e929e9299c
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
+ PATH
13
+ remote: .
14
+ specs:
15
+ deviseOne (1.0.0)
16
+ bcrypt (~> 3.0)
17
+ multimap
18
+ orm_adapter (~> 0.1)
19
+ railties (>= 3.2.6, < 5)
20
+ responders
21
+ rest-client (~> 1.7.2)
22
+ thread_safe (~> 0.1)
23
+ warden (~> 1.2.3)
24
+
25
+ GEM
26
+ remote: https://rubygems.org/
27
+ specs:
28
+ actionmailer (4.2.0.rc3)
29
+ actionpack (= 4.2.0.rc3)
30
+ actionview (= 4.2.0.rc3)
31
+ activejob (= 4.2.0.rc3)
32
+ mail (~> 2.5, >= 2.5.4)
33
+ rails-dom-testing (~> 1.0, >= 1.0.5)
34
+ actionpack (4.2.0.rc3)
35
+ actionview (= 4.2.0.rc3)
36
+ activesupport (= 4.2.0.rc3)
37
+ rack (~> 1.6.0.beta2)
38
+ rack-test (~> 0.6.2)
39
+ rails-dom-testing (~> 1.0, >= 1.0.5)
40
+ rails-html-sanitizer (~> 1.0, >= 1.0.1)
41
+ actionview (4.2.0.rc3)
42
+ activesupport (= 4.2.0.rc3)
43
+ builder (~> 3.1)
44
+ erubis (~> 2.7.0)
45
+ rails-dom-testing (~> 1.0, >= 1.0.5)
46
+ rails-html-sanitizer (~> 1.0, >= 1.0.1)
47
+ activejob (4.2.0.rc3)
48
+ activesupport (= 4.2.0.rc3)
49
+ globalid (>= 0.3.0)
50
+ activemodel (4.2.0.rc3)
51
+ activesupport (= 4.2.0.rc3)
52
+ builder (~> 3.1)
53
+ activerecord (4.2.0.rc3)
54
+ activemodel (= 4.2.0.rc3)
55
+ activesupport (= 4.2.0.rc3)
56
+ arel (~> 6.0)
57
+ activesupport (4.2.0.rc3)
58
+ i18n (>= 0.7.0.beta1, < 0.8)
59
+ json (~> 1.7, >= 1.7.7)
60
+ minitest (~> 5.1)
61
+ thread_safe (~> 0.1)
62
+ tzinfo (~> 1.1)
63
+ arel (6.0.0)
64
+ bcrypt (3.1.9)
65
+ bson (2.3.0)
66
+ builder (3.2.2)
67
+ connection_pool (2.1.0)
68
+ erubis (2.7.0)
69
+ faraday (0.9.0)
70
+ multipart-post (>= 1.2, < 3)
71
+ globalid (0.3.0)
72
+ activesupport (>= 4.1.0)
73
+ hashie (3.3.2)
74
+ hike (1.2.3)
75
+ i18n (0.7.0.beta1)
76
+ json (1.8.1)
77
+ jwt (1.2.0)
78
+ loofah (2.0.1)
79
+ nokogiri (>= 1.5.9)
80
+ mail (2.6.3)
81
+ mime-types (>= 1.16, < 3)
82
+ metaclass (0.0.4)
83
+ mime-types (2.4.3)
84
+ mini_portile (0.6.1)
85
+ minitest (5.5.0)
86
+ mocha (1.1.0)
87
+ metaclass (~> 0.0.1)
88
+ moped (2.0.2)
89
+ bson (~> 2.2)
90
+ connection_pool (~> 2.0)
91
+ optionable (~> 0.2.0)
92
+ multi_json (1.10.1)
93
+ multi_xml (0.5.5)
94
+ multimap (1.1.3)
95
+ multipart-post (2.0.0)
96
+ netrc (0.10.2)
97
+ nokogiri (1.6.5)
98
+ mini_portile (~> 0.6.0)
99
+ oauth2 (0.9.4)
100
+ faraday (>= 0.8, < 0.10)
101
+ jwt (~> 1.0)
102
+ multi_json (~> 1.3)
103
+ multi_xml (~> 0.5)
104
+ rack (~> 1.2)
105
+ omniauth (1.2.2)
106
+ hashie (>= 1.2, < 4)
107
+ rack (~> 1.0)
108
+ omniauth-facebook (1.6.0)
109
+ omniauth-oauth2 (~> 1.1)
110
+ omniauth-oauth2 (1.1.2)
111
+ faraday (>= 0.8, < 0.10)
112
+ multi_json (~> 1.3)
113
+ oauth2 (~> 0.9.3)
114
+ omniauth (~> 1.2)
115
+ omniauth-openid (1.0.1)
116
+ omniauth (~> 1.0)
117
+ rack-openid (~> 1.3.1)
118
+ optionable (0.2.0)
119
+ origin (2.1.1)
120
+ orm_adapter (0.5.0)
121
+ rack (1.6.0.beta2)
122
+ rack-openid (1.3.1)
123
+ rack (>= 1.1.0)
124
+ ruby-openid (>= 2.1.8)
125
+ rack-test (0.6.2)
126
+ rack (>= 1.0)
127
+ rails (4.2.0.rc3)
128
+ actionmailer (= 4.2.0.rc3)
129
+ actionpack (= 4.2.0.rc3)
130
+ actionview (= 4.2.0.rc3)
131
+ activejob (= 4.2.0.rc3)
132
+ activemodel (= 4.2.0.rc3)
133
+ activerecord (= 4.2.0.rc3)
134
+ activesupport (= 4.2.0.rc3)
135
+ bundler (>= 1.3.0, < 2.0)
136
+ railties (= 4.2.0.rc3)
137
+ sprockets-rails
138
+ rails-deprecated_sanitizer (1.0.3)
139
+ activesupport (>= 4.2.0.alpha)
140
+ rails-dom-testing (1.0.5)
141
+ activesupport (>= 4.2.0.beta, < 5.0)
142
+ nokogiri (~> 1.6.0)
143
+ rails-deprecated_sanitizer (>= 1.0.1)
144
+ rails-html-sanitizer (1.0.1)
145
+ loofah (~> 2.0)
146
+ railties (4.2.0.rc3)
147
+ actionpack (= 4.2.0.rc3)
148
+ activesupport (= 4.2.0.rc3)
149
+ rake (>= 0.8.7)
150
+ thor (>= 0.18.1, < 2.0)
151
+ rake (10.4.2)
152
+ rdoc (4.1.2)
153
+ json (~> 1.4)
154
+ responders (2.0.2)
155
+ railties (>= 4.2.0.alpha, < 5)
156
+ rest-client (1.7.2)
157
+ mime-types (>= 1.16, < 3.0)
158
+ netrc (~> 0.7)
159
+ ruby-openid (2.6.0)
160
+ sprockets (2.12.3)
161
+ hike (~> 1.2)
162
+ multi_json (~> 1.0)
163
+ rack (~> 1.0)
164
+ tilt (~> 1.1, != 1.3.0)
165
+ sprockets-rails (2.2.2)
166
+ actionpack (>= 3.0)
167
+ activesupport (>= 3.0)
168
+ sprockets (>= 2.8, < 4.0)
169
+ sqlite3 (1.3.10)
170
+ thor (0.19.1)
171
+ thread_safe (0.3.4)
172
+ tilt (1.4.1)
173
+ tzinfo (1.2.2)
174
+ thread_safe (~> 0.1)
175
+ warden (1.2.3)
176
+ rack (>= 1.0)
177
+ webrat (0.7.3)
178
+ nokogiri (>= 1.2.0)
179
+ rack (>= 1.0)
180
+ rack-test (>= 0.5.3)
181
+
182
+ PLATFORMS
183
+ ruby
184
+
185
+ DEPENDENCIES
186
+ activerecord-jdbc-adapter
187
+ activerecord-jdbcsqlite3-adapter
188
+ deviseOne!
189
+ jruby-openssl
190
+ mocha (~> 1.1)
191
+ mongoid!
192
+ omniauth (~> 1.2.0)
193
+ omniauth-facebook
194
+ omniauth-oauth2 (~> 1.1.0)
195
+ omniauth-openid (~> 1.0.1)
196
+ rails (= 4.2.0.rc3)
197
+ rdoc
198
+ sqlite3
199
+ webrat (= 0.7.3)
@@ -0,0 +1,20 @@
1
+ Copyright 2009-2014 Plataformatec. http://plataformatec.com.br
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,529 @@
1
+ ![Devise Logo](https://raw.github.com/plataformatec/devise/master/devise.png)
2
+
3
+ By [Plataformatec](http://plataformatec.com.br/).
4
+
5
+ [![Build Status](https://api.travis-ci.org/plataformatec/devise.png?branch=master)](http://travis-ci.org/plataformatec/devise)
6
+ [![Code Climate](https://codeclimate.com/github/plataformatec/devise.png)](https://codeclimate.com/github/plataformatec/devise)
7
+ [![Security](https://hakiri.io/github/plataformatec/devise/master.svg)](https://hakiri.io/github/plataformatec/devise/master)
8
+
9
+ This README is [also available in a friendly navigable format](http://devise.plataformatec.com.br/).
10
+
11
+ Devise is a flexible authentication solution for Rails based on Warden. It:
12
+
13
+ * Is Rack based;
14
+ * Is a complete MVC solution based on Rails engines;
15
+ * Allows you to have multiple models signed in at the same time;
16
+ * Is based on a modularity concept: use only what you really need.
17
+
18
+ It's composed of 10 modules:
19
+
20
+ * [Database Authenticatable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/DatabaseAuthenticatable): encrypts and stores a password in the database to validate the authenticity of a user while signing in. The authentication can be done both through POST requests or HTTP Basic Authentication.
21
+ * [Omniauthable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Omniauthable): adds OmniAuth (https://github.com/intridea/omniauth) support.
22
+ * [Confirmable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Confirmable): sends emails with confirmation instructions and verifies whether an account is already confirmed during sign in.
23
+ * [Recoverable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Recoverable): resets the user password and sends reset instructions.
24
+ * [Registerable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Registerable): handles signing up users through a registration process, also allowing them to edit and destroy their account.
25
+ * [Rememberable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Rememberable): manages generating and clearing a token for remembering the user from a saved cookie.
26
+ * [Trackable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Trackable): tracks sign in count, timestamps and IP address.
27
+ * [Timeoutable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Timeoutable): expires sessions that have not been active in a specified period of time.
28
+ * [Validatable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Validatable): provides validations of email and password. It's optional and can be customized, so you're able to define your own validations.
29
+ * [Lockable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Lockable): locks an account after a specified number of failed sign-in attempts. Can unlock via email or after a specified time period.
30
+
31
+ Devise is guaranteed to be thread-safe on YARV. Thread-safety support on JRuby is in progress.
32
+
33
+ ## Information
34
+
35
+ ### The Devise wiki
36
+
37
+ 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:
38
+
39
+ https://github.com/plataformatec/devise/wiki
40
+
41
+ ### Bug reports
42
+
43
+ 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:
44
+
45
+ https://github.com/plataformatec/devise/wiki/Bug-reports
46
+
47
+ If you have discovered a security related bug, please do *NOT* use the GitHub issue tracker. Send an email to opensource@plataformatec.com.br.
48
+
49
+ ### Mailing list
50
+
51
+ If you have any questions, comments, or concerns, please use the Google Group instead of the GitHub issue tracker:
52
+
53
+ https://groups.google.com/group/plataformatec-devise
54
+
55
+ ### RDocs
56
+
57
+ You can view the Devise documentation in RDoc format here:
58
+
59
+ http://rubydoc.info/github/plataformatec/devise/master/frames
60
+
61
+ If you need to use Devise with previous versions of Rails, you can always run "gem server" from the command line after you install the gem to access the old documentation.
62
+
63
+ ### Example applications
64
+
65
+ 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:
66
+
67
+ https://github.com/plataformatec/devise/wiki/Example-Applications
68
+
69
+ ### Extensions
70
+
71
+ 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:
72
+
73
+ https://github.com/plataformatec/devise/wiki/Extensions
74
+
75
+ ### Contributing
76
+
77
+ We hope that you will consider contributing to Devise. Please read this short overview for some information about how to get started:
78
+
79
+ https://github.com/plataformatec/devise/wiki/Contributing
80
+
81
+ You will usually want to write tests for your changes. To run the test suite, go into Devise's top-level directory and run "bundle install" and "rake". For the tests to pass, you will need to have a MongoDB server (version 2.0 or newer) running on your system.
82
+
83
+ ## Starting with Rails?
84
+
85
+ If you are building your first Rails application, we recommend you *do not* use Devise. Devise requires a good understanding of the Rails Framework. In such cases, we advise you to start a simple authentication system from scratch. Today we have two resources that should help you get started:
86
+
87
+ * Michael Hartl's online book: https://www.railstutorial.org/book/modeling_users
88
+ * Ryan Bates' Railscast: http://railscasts.com/episodes/250-authentication-from-scratch
89
+
90
+ Once you have solidified your understanding of Rails and authentication mechanisms, we assure you Devise will be very pleasant to work with. :smiley:
91
+
92
+ ## Getting started
93
+
94
+ Devise 3.0 works with Rails 3.2 onwards. You can add it to your Gemfile with:
95
+
96
+ ```ruby
97
+ gem 'devise'
98
+ ```
99
+
100
+ Run the bundle command to install it.
101
+
102
+ After you install Devise and add it to your Gemfile, you need to run the generator:
103
+
104
+ ```console
105
+ rails generate devise:install
106
+ ```
107
+
108
+ The generator will install an initializer which describes ALL of Devise's configuration options. It is *imperative* that you take a look at it. When you are done, you are ready to add Devise to any of your models using the generator:
109
+
110
+ ```console
111
+ rails generate devise MODEL
112
+ ```
113
+
114
+ Replace MODEL with the class name used for the application’s users (it’s frequently `User` but could also be `Admin`). This will create a model (if one does not exist) and configure it with default Devise modules. The generator also configures your `config/routes.rb` file to point to the Devise controller.
115
+
116
+ Next, check the MODEL for any additional configuration options you might want to add, such as confirmable or lockable. If you add an option, be sure to inspect the migration file (created by the generator if your ORM supports them) and uncomment the appropriate section. For example, if you add the confirmable option in the model, you'll need to uncomment the Confirmable section in the migration. Then run `rake db:migrate`
117
+
118
+ Next, you need to set up the default URL options for the Devise mailer in each environment. Here is a possible configuration for `config/environments/development.rb`:
119
+
120
+ ```ruby
121
+ config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
122
+ ```
123
+
124
+ You should restart your application after changing Devise's configuration options. Otherwise, you will run into strange errors, for example, users being unable to login and route helpers being undefined.
125
+
126
+ ### Controller filters and helpers
127
+
128
+ Devise will create some helpers to use inside your controllers and views. To set up a controller with user authentication, just add this before_action (assuming your devise model is 'User'):
129
+
130
+ ```ruby
131
+ before_action :authenticate_user!
132
+ ```
133
+
134
+ If your devise model is something other than User, replace "_user" with "_yourmodel". The same logic applies to the instructions below.
135
+
136
+ To verify if a user is signed in, use the following helper:
137
+
138
+ ```ruby
139
+ user_signed_in?
140
+ ```
141
+
142
+ For the current signed-in user, this helper is available:
143
+
144
+ ```ruby
145
+ current_user
146
+ ```
147
+
148
+ You can access the session for this scope:
149
+
150
+ ```ruby
151
+ user_session
152
+ ```
153
+
154
+ After signing in a user, confirming the account or updating the password, Devise will look for a scoped root path to redirect to. For instance, when using a `:user` resource, the `user_root_path` will be used if it exists; otherwise, the default `root_path` will be used. This means that you need to set the root inside your routes:
155
+
156
+ ```ruby
157
+ root to: "home#index"
158
+ ```
159
+
160
+ You can also override `after_sign_in_path_for` and `after_sign_out_path_for` to customize your redirect hooks.
161
+
162
+ Notice that if your Devise model is called `Member` instead of `User`, for example, then the helpers available are:
163
+
164
+ ```ruby
165
+ before_action :authenticate_member!
166
+
167
+ member_signed_in?
168
+
169
+ current_member
170
+
171
+ member_session
172
+ ```
173
+
174
+ ### Configuring Models
175
+
176
+ The Devise method in your models also accepts some options to configure its modules. For example, you can choose the cost of the encryption algorithm with:
177
+
178
+ ```ruby
179
+ devise :database_authenticatable, :registerable, :confirmable, :recoverable, stretches: 20
180
+ ```
181
+
182
+ Besides `:stretches`, you can define `:pepper`, `:encryptor`, `:confirm_within`, `:remember_for`, `:timeout_in`, `:unlock_in` among other options. For more details, see the initializer file that was created when you invoked the "devise:install" generator described above. This file is usually located at `/config/initializers/devise.rb`.
183
+
184
+ ### Strong Parameters
185
+
186
+ When you customize your own views, you may end up adding new attributes to forms. Rails 4 moved the parameter sanitization from the model to the controller, causing Devise to handle this concern at the controller as well.
187
+
188
+ There are just three actions in Devise that allows any set of parameters to be passed down to the model, therefore requiring sanitization. Their names and the permitted parameters by default are:
189
+
190
+ * `sign_in` (`Devise::SessionsController#create`) - Permits only the authentication keys (like `email`)
191
+ * `sign_up` (`Devise::RegistrationsController#create`) - Permits authentication keys plus `password` and `password_confirmation`
192
+ * `account_update` (`Devise::RegistrationsController#update`) - Permits authentication keys plus `password`, `password_confirmation` and `current_password`
193
+
194
+ In case you want to permit additional parameters (the lazy way™), you can do so using a simple before filter in your `ApplicationController`:
195
+
196
+ ```ruby
197
+ class ApplicationController < ActionController::Base
198
+ before_action :configure_permitted_parameters, if: :devise_controller?
199
+
200
+ protected
201
+
202
+ def configure_permitted_parameters
203
+ devise_parameter_sanitizer.for(:sign_up) << :username
204
+ end
205
+ end
206
+ ```
207
+
208
+ The above works for any additional fields where the parameters are simple scalar types. If you have nested attributes (say you're using `accepts_nested_attributes_for`), then you will need to tell devise about those nestings and types. Devise allows you to completely change Devise defaults or invoke custom behaviour by passing a block:
209
+
210
+ To permit simple scalar values for username and email, use this
211
+
212
+ ```ruby
213
+ def configure_permitted_parameters
214
+ devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:username, :email) }
215
+ end
216
+ ```
217
+
218
+ If you have some checkboxes that express the roles a user may take on registration, the browser will send those selected checkboxes as an array. An array is not one of Strong Parameters' permitted scalars, so we need to configure Devise in the following way:
219
+
220
+ ```ruby
221
+ def configure_permitted_parameters
222
+ devise_parameter_sanitizer.for(:sign_up) { |u| u.permit({ roles: [] }, :email, :password, :password_confirmation) }
223
+ end
224
+ ```
225
+ For the list of permitted scalars, and how to declare permitted keys in nested hashes and arrays, see
226
+
227
+ https://github.com/rails/strong_parameters#nested-parameters
228
+
229
+ If you have multiple Devise models, you may want to set up a different parameter sanitizer per model. In this case, we recommend inheriting from `Devise::ParameterSanitizer` and adding your own logic:
230
+
231
+ ```ruby
232
+ class User::ParameterSanitizer < Devise::ParameterSanitizer
233
+ def sign_in
234
+ default_params.permit(:username, :email)
235
+ end
236
+ end
237
+ ```
238
+
239
+ And then configure your controllers to use it:
240
+
241
+ ```ruby
242
+ class ApplicationController < ActionController::Base
243
+ protected
244
+
245
+ def devise_parameter_sanitizer
246
+ if resource_class == User
247
+ User::ParameterSanitizer.new(User, :user, params)
248
+ else
249
+ super # Use the default one
250
+ end
251
+ end
252
+ end
253
+ ```
254
+
255
+ The example above overrides the permitted parameters for the user to be both `:username` and `:email`. The non-lazy way to configure parameters would be by defining the before filter above in a custom controller. We detail how to configure and customize controllers in some sections below.
256
+
257
+ ### Configuring views
258
+
259
+ 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.
260
+
261
+ Since Devise is an engine, all its views are packaged inside the gem. These views will help you get started, but after some time you may want to change them. If this is the case, you just need to invoke the following generator, and it will copy all views to your application:
262
+
263
+ ```console
264
+ rails generate devise:views
265
+ ```
266
+
267
+ If you have more than one Devise model in your application (such as `User` and `Admin`), you will notice that Devise uses the same views for all models. Fortunately, Devise offers an easy way to customize views. All you need to do is set `config.scoped_views = true` inside the `config/initializers/devise.rb` file.
268
+
269
+ 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:
270
+
271
+ ```console
272
+ rails generate devise:views users
273
+ ```
274
+
275
+ If you would like to generate only a few sets of views, like the ones for the `registerable` and `confirmable` module,
276
+ you can pass a list of modules to the generator with the `-v` flag.
277
+
278
+ ```console
279
+ rails generate devise:views -v registrations confirmations
280
+ ```
281
+
282
+ ### Configuring controllers
283
+
284
+ If the customization at the views level is not enough, you can customize each controller by following these steps:
285
+
286
+ 1. Create your custom controllers using the generator which requires a scope:
287
+
288
+ ```console
289
+ rails generate devise:controllers [scope]
290
+ ```
291
+
292
+ If you specify `users` as the scope, controllers will be created in `app/controllers/users/`.
293
+ And the sessions controller will look like this:
294
+
295
+ ```ruby
296
+ class Users::SessionsController < Devise::SessionsController
297
+ # GET /resource/sign_in
298
+ # def new
299
+ # super
300
+ # end
301
+ ...
302
+ end
303
+ ```
304
+
305
+ 2. Tell the router to use this controller:
306
+
307
+ ```ruby
308
+ devise_for :users, controllers: { sessions: "users/sessions" }
309
+ ```
310
+
311
+ 3. Copy the views from `devise/sessions` to `users/sessions`. Since the controller was changed, it won't use the default views located in `devise/sessions`.
312
+
313
+ 4. Finally, change or extend the desired controller actions.
314
+
315
+ You can completely override a controller action:
316
+
317
+ ```ruby
318
+ class Users::SessionsController < Devise::SessionsController
319
+ def create
320
+ # custom sign-in code
321
+ end
322
+ end
323
+ ```
324
+
325
+ Or you can simply add new behaviour to it:
326
+
327
+ ```ruby
328
+ class Users::SessionsController < Devise::SessionsController
329
+ def create
330
+ super do |resource|
331
+ BackgroundWorker.trigger(resource)
332
+ end
333
+ end
334
+ end
335
+ ```
336
+
337
+ This is useful for triggering background jobs or logging events during certain actions.
338
+
339
+ Remember that Devise uses flash messages to let users know if sign in was successful or unsuccessful. Devise expects your application to call `flash[:notice]` and `flash[:alert]` as appropriate. Do not print the entire flash hash, print only specific keys. In some circumstances, Devise adds a `:timedout` key to the flash hash, which is not meant for display. Remove this key from the hash if you intend to print the entire hash.
340
+
341
+ ### Configuring routes
342
+
343
+ 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:
344
+
345
+ ```ruby
346
+ devise_for :users, path: "auth", path_names: { sign_in: 'login', sign_out: 'logout', password: 'secret', confirmation: 'verification', unlock: 'unblock', registration: 'register', sign_up: 'cmon_let_me_in' }
347
+ ```
348
+
349
+ Be sure to check `devise_for` documentation for details.
350
+
351
+ 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:
352
+
353
+ ```ruby
354
+ devise_scope :user do
355
+ get "sign_in", to: "devise/sessions#new"
356
+ end
357
+ ```
358
+
359
+ This way, you tell Devise to use the scope `:user` when "/sign_in" is accessed. Notice `devise_scope` is also aliased as `as` in your router.
360
+
361
+ ### I18n
362
+
363
+ Devise uses flash messages with I18n, in conjunction with the flash keys :notice and :alert. To customize your app, you can set up your locale file:
364
+
365
+ ```yaml
366
+ en:
367
+ devise:
368
+ sessions:
369
+ signed_in: 'Signed in successfully.'
370
+ ```
371
+
372
+ You can also create distinct messages based on the resource you've configured using the singular name given in routes:
373
+
374
+ ```yaml
375
+ en:
376
+ devise:
377
+ sessions:
378
+ user:
379
+ signed_in: 'Welcome user, you are signed in.'
380
+ admin:
381
+ signed_in: 'Hello admin!'
382
+ ```
383
+
384
+ The Devise mailer uses a similar pattern to create subject messages:
385
+
386
+ ```yaml
387
+ en:
388
+ devise:
389
+ mailer:
390
+ confirmation_instructions:
391
+ subject: 'Hello everybody!'
392
+ user_subject: 'Hello User! Please confirm your email'
393
+ reset_password_instructions:
394
+ subject: 'Reset instructions'
395
+ ```
396
+
397
+ 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:
398
+
399
+ https://github.com/plataformatec/devise/wiki/I18n
400
+
401
+ Caution: Devise Controllers inherit from ApplicationController. If your app uses multiple locales, you should be sure to set I18n.locale in ApplicationController.
402
+
403
+ ### Test helpers
404
+
405
+ Devise includes some test helpers for functional specs. In order to use them, you need to include Devise in your functional tests by adding the following to the bottom of your `test/test_helper.rb` file:
406
+
407
+ ```ruby
408
+ class ActionController::TestCase
409
+ include Devise::TestHelpers
410
+ end
411
+ ```
412
+
413
+ If you're using RSpec, you can put the following inside a file named `spec/support/devise.rb` or in your `spec/spec_helper.rb` (or `spec/rails_helper.rb` if you are using rspec-rails):
414
+
415
+ ```ruby
416
+ RSpec.configure do |config|
417
+ config.include Devise::TestHelpers, type: :controller
418
+ end
419
+ ```
420
+
421
+ Now you are ready to use the `sign_in` and `sign_out` methods. Such methods have the same signature as in controllers:
422
+
423
+ ```ruby
424
+ sign_in :user, @user # sign_in(scope, resource)
425
+ sign_in @user # sign_in(resource)
426
+
427
+ sign_out :user # sign_out(scope)
428
+ sign_out @user # sign_out(resource)
429
+ ```
430
+
431
+ There are two things that are important to keep in mind:
432
+
433
+ 1. These helpers are not going to work for integration tests driven by Capybara or Webrat. They are meant to be used with functional tests only. Instead, fill in the form or explicitly set the user in session;
434
+
435
+ 2. If you are testing Devise internal controllers or a controller that inherits from Devise's, you need to tell Devise which mapping should be used before a request. This is necessary because Devise gets this information from the router, but since functional tests do not pass through the router, it needs to be stated explicitly. For example, if you are testing the user scope, simply use:
436
+
437
+ ```ruby
438
+ @request.env["devise.mapping"] = Devise.mappings[:user]
439
+ get :new
440
+ ```
441
+
442
+ ### OmniAuth
443
+
444
+ Devise comes with OmniAuth support out of the box to authenticate with other providers. To use it, simply specify your OmniAuth configuration in `config/initializers/devise.rb`:
445
+
446
+ ```ruby
447
+ config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
448
+ ```
449
+
450
+ You can read more about OmniAuth support in the wiki:
451
+
452
+ * https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview
453
+
454
+ ### Configuring multiple models
455
+
456
+ Devise allows you to set up as many Devise models as you want. If you want to have an Admin model with just authentication and timeout features, in addition to the User model above, just run:
457
+
458
+ ```ruby
459
+ # Create a migration with the required fields
460
+ create_table :admins do |t|
461
+ t.string :email
462
+ t.string :encrypted_password
463
+ t.timestamps
464
+ end
465
+
466
+ # Inside your Admin model
467
+ devise :database_authenticatable, :timeoutable
468
+
469
+ # Inside your routes
470
+ devise_for :admins
471
+
472
+ # Inside your protected controller
473
+ before_filter :authenticate_admin!
474
+
475
+ # Inside your controllers and views
476
+ admin_signed_in?
477
+ current_admin
478
+ admin_session
479
+ ```
480
+
481
+ Alternatively, you can simply run the Devise generator.
482
+
483
+ Keep in mind that those models will have completely different routes. They **do not** and **cannot** share the same controller for sign in, sign out and so on. In case you want to have different roles sharing the same actions, we recommend that you use a role-based approach, by either providing a role column or using a dedicated gem for authorization.
484
+
485
+ ### ActiveJob Integration
486
+
487
+ If you are using Rails 4.2 and ActiveJob to deliver ActionMailer messages in the
488
+ background through a queuing back-end, you can send Devise emails through your
489
+ existing queue by overriding the `send_devise_notification` method in your model.
490
+
491
+ ```ruby
492
+ def send_devise_notification(notification, *args)
493
+ devise_mailer.send(notification, self, *args).deliver_later
494
+ end
495
+ ```
496
+
497
+ ### Other ORMs
498
+
499
+ Devise supports ActiveRecord (default) and Mongoid. To select another ORM, simply require it in the initializer file.
500
+
501
+ ## Additional information
502
+
503
+ ### Heroku
504
+
505
+ Using Devise on Heroku with Ruby on Rails 3.1 requires setting:
506
+
507
+ ```ruby
508
+ config.assets.initialize_on_precompile = false
509
+ ```
510
+
511
+ Read more about the potential issues at http://guides.rubyonrails.org/asset_pipeline.html
512
+
513
+ ### Warden
514
+
515
+ 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:
516
+
517
+ https://github.com/hassox/warden
518
+
519
+ ### Contributors
520
+
521
+ We have a long list of valued contributors. Check them all at:
522
+
523
+ https://github.com/plataformatec/devise/graphs/contributors
524
+
525
+ ## License
526
+
527
+ MIT License. Copyright 2009-2014 Plataformatec. http://plataformatec.com.br
528
+
529
+ You are not granted rights or licenses to the trademarks of Plataformatec, including without limitation the Devise name or logo.