deviseOne 1.0.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.
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,55 @@
1
+ require 'rails/generators/named_base'
2
+ require 'generators/devise/orm_helpers'
3
+
4
+ module Mongoid
5
+ module Generators
6
+ class DeviseGenerator < Rails::Generators::NamedBase
7
+ include Devise::Generators::OrmHelpers
8
+
9
+ def generate_model
10
+ invoke "mongoid:model", [name] unless model_exists? && behavior == :invoke
11
+ end
12
+
13
+ def inject_field_types
14
+ inject_into_file model_path, migration_data, after: "include Mongoid::Document\n" if model_exists?
15
+ end
16
+
17
+ def inject_devise_content
18
+ inject_into_file model_path, model_contents, after: "include Mongoid::Document\n" if model_exists?
19
+ end
20
+
21
+ def migration_data
22
+ <<RUBY
23
+ ## Database authenticatable
24
+ field :email, type: String, default: ""
25
+ field :encrypted_password, type: String, default: ""
26
+
27
+ ## Recoverable
28
+ field :reset_password_token, type: String
29
+ field :reset_password_sent_at, type: Time
30
+
31
+ ## Rememberable
32
+ field :remember_created_at, type: Time
33
+
34
+ ## Trackable
35
+ field :sign_in_count, type: Integer, default: 0
36
+ field :current_sign_in_at, type: Time
37
+ field :last_sign_in_at, type: Time
38
+ field :current_sign_in_ip, type: String
39
+ field :last_sign_in_ip, type: String
40
+
41
+ ## Confirmable
42
+ # field :confirmation_token, type: String
43
+ # field :confirmed_at, type: Time
44
+ # field :confirmation_sent_at, type: Time
45
+ # field :unconfirmed_email, type: String # Only if using reconfirmable
46
+
47
+ ## Lockable
48
+ # field :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts
49
+ # field :unlock_token, type: String # Only if unlock strategy is :email or :both
50
+ # field :locked_at, type: Time
51
+ RUBY
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,35 @@
1
+ ===============================================================================
2
+
3
+ Some setup you must do manually if you haven't yet:
4
+
5
+ 1. Ensure you have defined default url options in your environments files. Here
6
+ is an example of default_url_options appropriate for a development environment
7
+ in config/environments/development.rb:
8
+
9
+ config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
10
+
11
+ In production, :host should be set to the actual host of your application.
12
+
13
+ 2. Ensure you have defined root_url to *something* in your config/routes.rb.
14
+ For example:
15
+
16
+ root to: "home#index"
17
+
18
+ 3. Ensure you have flash messages in app/views/layouts/application.html.erb.
19
+ For example:
20
+
21
+ <p class="notice"><%= notice %></p>
22
+ <p class="alert"><%= alert %></p>
23
+
24
+ 4. If you are deploying on Heroku with Rails 3.2 only, you may want to set:
25
+
26
+ config.assets.initialize_on_precompile = false
27
+
28
+ On config/application.rb forcing your application to not access the DB
29
+ or load models when precompiling your assets.
30
+
31
+ 5. You can copy Devise views (for customization) to your app by running:
32
+
33
+ rails g devise:views
34
+
35
+ ===============================================================================
@@ -0,0 +1,14 @@
1
+ ===============================================================================
2
+
3
+ Some setup you must do manually if you haven't yet:
4
+
5
+ Ensure you have overridden routes for generated controllers in your route.rb.
6
+ For example:
7
+
8
+ Rails.application.routes.draw do
9
+ devise_for :users, controllers: {
10
+ sessions: 'sessions'
11
+ }
12
+ end
13
+
14
+ ===============================================================================
@@ -0,0 +1,28 @@
1
+ class <%= @scope_prefix %>ConfirmationsController < Devise::ConfirmationsController
2
+ # GET /resource/confirmation/new
3
+ # def new
4
+ # super
5
+ # end
6
+
7
+ # POST /resource/confirmation
8
+ # def create
9
+ # super
10
+ # end
11
+
12
+ # GET /resource/confirmation?confirmation_token=abcdef
13
+ # def show
14
+ # super
15
+ # end
16
+
17
+ # protected
18
+
19
+ # The path used after resending confirmation instructions.
20
+ # def after_resending_confirmation_instructions_path_for(resource_name)
21
+ # super(resource_name)
22
+ # end
23
+
24
+ # The path used after confirmation.
25
+ # def after_confirmation_path_for(resource_name, resource)
26
+ # super(resource_name, resource)
27
+ # end
28
+ end
@@ -0,0 +1,28 @@
1
+ class <%= @scope_prefix %>OmniauthCallbacksController < Devise::OmniauthCallbacksController
2
+ # You should configure your model like this:
3
+ # devise :omniauthable, omniauth_providers: [:twitter]
4
+
5
+ # You should also create an action method in this controller like this:
6
+ # def twitter
7
+ # end
8
+
9
+ # More info at:
10
+ # https://github.com/plataformatec/devise#omniauth
11
+
12
+ # GET|POST /resource/auth/twitter
13
+ # def passthru
14
+ # super
15
+ # end
16
+
17
+ # GET|POST /users/auth/twitter/callback
18
+ # def failure
19
+ # super
20
+ # end
21
+
22
+ # protected
23
+
24
+ # The path used when OmniAuth fails
25
+ # def after_omniauth_failure_path_for(scope)
26
+ # super(scope)
27
+ # end
28
+ end
@@ -0,0 +1,32 @@
1
+ class <%= @scope_prefix %>PasswordsController < Devise::PasswordsController
2
+ # GET /resource/password/new
3
+ # def new
4
+ # super
5
+ # end
6
+
7
+ # POST /resource/password
8
+ # def create
9
+ # super
10
+ # end
11
+
12
+ # GET /resource/password/edit?reset_password_token=abcdef
13
+ # def edit
14
+ # super
15
+ # end
16
+
17
+ # PUT /resource/password
18
+ # def update
19
+ # super
20
+ # end
21
+
22
+ # protected
23
+
24
+ # def after_resetting_password_path_for(resource)
25
+ # super(resource)
26
+ # end
27
+
28
+ # The path used after sending reset password instructions
29
+ # def after_sending_reset_password_instructions_path_for(resource_name)
30
+ # super(resource_name)
31
+ # end
32
+ end
@@ -0,0 +1,60 @@
1
+ class <%= @scope_prefix %>RegistrationsController < Devise::RegistrationsController
2
+ # before_filter :configure_sign_up_params, only: [:create]
3
+ # before_filter :configure_account_update_params, only: [:update]
4
+
5
+ # GET /resource/sign_up
6
+ # def new
7
+ # super
8
+ # end
9
+
10
+ # POST /resource
11
+ # def create
12
+ # super
13
+ # end
14
+
15
+ # GET /resource/edit
16
+ # def edit
17
+ # super
18
+ # end
19
+
20
+ # PUT /resource
21
+ # def update
22
+ # super
23
+ # end
24
+
25
+ # DELETE /resource
26
+ # def destroy
27
+ # super
28
+ # end
29
+
30
+ # GET /resource/cancel
31
+ # Forces the session data which is usually expired after sign
32
+ # in to be expired now. This is useful if the user wants to
33
+ # cancel oauth signing in/up in the middle of the process,
34
+ # removing all OAuth session data.
35
+ # def cancel
36
+ # super
37
+ # end
38
+
39
+ # protected
40
+
41
+ # You can put the params you want to permit in the empty array.
42
+ # def configure_sign_up_params
43
+ # devise_parameter_sanitizer.for(:sign_up) << :attribute
44
+ # end
45
+
46
+ # You can put the params you want to permit in the empty array.
47
+ # def configure_account_update_params
48
+ # devise_parameter_sanitizer.for(:account_update) << :attribute
49
+ # end
50
+
51
+ # The path used after sign up.
52
+ # def after_sign_up_path_for(resource)
53
+ # super(resource)
54
+ # end
55
+
56
+ # The path used after sign up for inactive accounts.
57
+ # def after_inactive_sign_up_path_for(resource)
58
+ # super(resource)
59
+ # end
60
+ end
@@ -0,0 +1,25 @@
1
+ class <%= @scope_prefix %>SessionsController < Devise::SessionsController
2
+ # before_filter :configure_sign_in_params, only: [:create]
3
+
4
+ # GET /resource/sign_in
5
+ # def new
6
+ # super
7
+ # end
8
+
9
+ # POST /resource/sign_in
10
+ # def create
11
+ # super
12
+ # end
13
+
14
+ # DELETE /resource/sign_out
15
+ # def destroy
16
+ # super
17
+ # end
18
+
19
+ # protected
20
+
21
+ # You can put the params you want to permit in the empty array.
22
+ # def configure_sign_in_params
23
+ # devise_parameter_sanitizer.for(:sign_in) << :attribute
24
+ # end
25
+ end
@@ -0,0 +1,28 @@
1
+ class <%= @scope_prefix %>UnlocksController < Devise::UnlocksController
2
+ # GET /resource/unlock/new
3
+ # def new
4
+ # super
5
+ # end
6
+
7
+ # POST /resource/unlock
8
+ # def create
9
+ # super
10
+ # end
11
+
12
+ # GET /resource/unlock?unlock_token=abcdef
13
+ # def show
14
+ # super
15
+ # end
16
+
17
+ # protected
18
+
19
+ # The path used after sending unlock password instructions
20
+ # def after_sending_unlock_instructions_path_for(resource)
21
+ # super(resource)
22
+ # end
23
+
24
+ # The path used after unlocking the resource
25
+ # def after_unlock_path_for(resource)
26
+ # super(resource)
27
+ # end
28
+ end
@@ -0,0 +1,263 @@
1
+ # Use this hook to configure devise mailer, warden hooks and so forth.
2
+ # Many of these configuration options can be set straight in your model.
3
+ Devise.setup do |config|
4
+ # The secret key used by Devise. Devise uses this key to generate
5
+ # random tokens. Changing this key will render invalid all existing
6
+ # confirmation, reset password and unlock tokens in the database.
7
+ <% if rails_4? -%>
8
+ # config.secret_key = '<%= SecureRandom.hex(64) %>'
9
+ <% else -%>
10
+ config.secret_key = '<%= SecureRandom.hex(64) %>'
11
+ <% end -%>
12
+
13
+ # ==> Mailer Configuration
14
+ # Configure the e-mail address which will be shown in Devise::Mailer,
15
+ # note that it will be overwritten if you use your own mailer class
16
+ # with default "from" parameter.
17
+ config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
18
+
19
+ # Configure the class responsible to send e-mails.
20
+ # config.mailer = 'Devise::Mailer'
21
+
22
+ # ==> ORM configuration
23
+ # Load and configure the ORM. Supports :active_record (default) and
24
+ # :mongoid (bson_ext recommended) by default. Other ORMs may be
25
+ # available as additional gems.
26
+ require 'devise/orm/<%= options[:orm] %>'
27
+
28
+ # ==> Configuration for any authentication mechanism
29
+ # Configure which keys are used when authenticating a user. The default is
30
+ # just :email. You can configure it to use [:username, :subdomain], so for
31
+ # authenticating a user, both parameters are required. Remember that those
32
+ # parameters are used only when authenticating and not when retrieving from
33
+ # session. If you need permissions, you should implement that in a before filter.
34
+ # You can also supply a hash where the value is a boolean determining whether
35
+ # or not authentication should be aborted when the value is not present.
36
+ # config.authentication_keys = [ :email ]
37
+
38
+ # Configure parameters from the request object used for authentication. Each entry
39
+ # given should be a request method and it will automatically be passed to the
40
+ # find_for_authentication method and considered in your model lookup. For instance,
41
+ # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
42
+ # The same considerations mentioned for authentication_keys also apply to request_keys.
43
+ # config.request_keys = []
44
+
45
+ # Configure which authentication keys should be case-insensitive.
46
+ # These keys will be downcased upon creating or modifying a user and when used
47
+ # to authenticate or find a user. Default is :email.
48
+ config.case_insensitive_keys = [ :email ]
49
+
50
+ # Configure which authentication keys should have whitespace stripped.
51
+ # These keys will have whitespace before and after removed upon creating or
52
+ # modifying a user and when used to authenticate or find a user. Default is :email.
53
+ config.strip_whitespace_keys = [ :email ]
54
+
55
+ # Tell if authentication through request.params is enabled. True by default.
56
+ # It can be set to an array that will enable params authentication only for the
57
+ # given strategies, for example, `config.params_authenticatable = [:database]` will
58
+ # enable it only for database (email + password) authentication.
59
+ # config.params_authenticatable = true
60
+
61
+ # Tell if authentication through HTTP Auth is enabled. False by default.
62
+ # It can be set to an array that will enable http authentication only for the
63
+ # given strategies, for example, `config.http_authenticatable = [:database]` will
64
+ # enable it only for database authentication. The supported strategies are:
65
+ # :database = Support basic authentication with authentication key + password
66
+ # config.http_authenticatable = false
67
+
68
+ # If 401 status code should be returned for AJAX requests. True by default.
69
+ # config.http_authenticatable_on_xhr = true
70
+
71
+ # The realm used in Http Basic Authentication. 'Application' by default.
72
+ # config.http_authentication_realm = 'Application'
73
+
74
+ # It will change confirmation, password recovery and other workflows
75
+ # to behave the same regardless if the e-mail provided was right or wrong.
76
+ # Does not affect registerable.
77
+ # config.paranoid = true
78
+
79
+ # By default Devise will store the user in session. You can skip storage for
80
+ # particular strategies by setting this option.
81
+ # Notice that if you are skipping storage for all authentication paths, you
82
+ # may want to disable generating routes to Devise's sessions controller by
83
+ # passing skip: :sessions to `devise_for` in your config/routes.rb
84
+ config.skip_session_storage = [:http_auth]
85
+
86
+ # By default, Devise cleans up the CSRF token on authentication to
87
+ # avoid CSRF token fixation attacks. This means that, when using AJAX
88
+ # requests for sign in and sign up, you need to get a new CSRF token
89
+ # from the server. You can disable this option at your own risk.
90
+ # config.clean_up_csrf_token_on_authentication = true
91
+
92
+ # ==> Configuration for :database_authenticatable
93
+ # For bcrypt, this is the cost for hashing the password and defaults to 10. If
94
+ # using other encryptors, it sets how many times you want the password re-encrypted.
95
+ #
96
+ # Limiting the stretches to just one in testing will increase the performance of
97
+ # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
98
+ # a value less than 10 in other environments. Note that, for bcrypt (the default
99
+ # encryptor), the cost increases exponentially with the number of stretches (e.g.
100
+ # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
101
+ config.stretches = Rails.env.test? ? 1 : 10
102
+
103
+ # Setup a pepper to generate the encrypted password.
104
+ # config.pepper = '<%= SecureRandom.hex(64) %>'
105
+
106
+ # ==> Configuration for :confirmable
107
+ # A period that the user is allowed to access the website even without
108
+ # confirming their account. For instance, if set to 2.days, the user will be
109
+ # able to access the website for two days without confirming their account,
110
+ # access will be blocked just in the third day. Default is 0.days, meaning
111
+ # the user cannot access the website without confirming their account.
112
+ # config.allow_unconfirmed_access_for = 2.days
113
+
114
+ # A period that the user is allowed to confirm their account before their
115
+ # token becomes invalid. For example, if set to 3.days, the user can confirm
116
+ # their account within 3 days after the mail was sent, but on the fourth day
117
+ # their account can't be confirmed with the token any more.
118
+ # Default is nil, meaning there is no restriction on how long a user can take
119
+ # before confirming their account.
120
+ # config.confirm_within = 3.days
121
+
122
+ # If true, requires any email changes to be confirmed (exactly the same way as
123
+ # initial account confirmation) to be applied. Requires additional unconfirmed_email
124
+ # db field (see migrations). Until confirmed, new email is stored in
125
+ # unconfirmed_email column, and copied to email column on successful confirmation.
126
+ config.reconfirmable = true
127
+
128
+ # Defines which key will be used when confirming an account
129
+ # config.confirmation_keys = [ :email ]
130
+
131
+ # ==> Configuration for :rememberable
132
+ # The time the user will be remembered without asking for credentials again.
133
+ # config.remember_for = 2.weeks
134
+
135
+ # Invalidates all the remember me tokens when the user signs out.
136
+ config.expire_all_remember_me_on_sign_out = true
137
+
138
+ # If true, extends the user's remember period when remembered via cookie.
139
+ # config.extend_remember_period = false
140
+
141
+ # Options to be passed to the created cookie. For instance, you can set
142
+ # secure: true in order to force SSL only cookies.
143
+ # config.rememberable_options = {}
144
+
145
+ # ==> Configuration for :validatable
146
+ # Range for password length.
147
+ config.password_length = 8..72
148
+
149
+ # Email regex used to validate email formats. It simply asserts that
150
+ # one (and only one) @ exists in the given string. This is mainly
151
+ # to give user feedback and not to assert the e-mail validity.
152
+ # config.email_regexp = /\A[^@]+@[^@]+\z/
153
+
154
+ # ==> Configuration for :timeoutable
155
+ # The time you want to timeout the user session without activity. After this
156
+ # time the user will be asked for credentials again. Default is 30 minutes.
157
+ # config.timeout_in = 30.minutes
158
+
159
+ # If true, expires auth token on session timeout.
160
+ # config.expire_auth_token_on_timeout = false
161
+
162
+ # ==> Configuration for :lockable
163
+ # Defines which strategy will be used to lock an account.
164
+ # :failed_attempts = Locks an account after a number of failed attempts to sign in.
165
+ # :none = No lock strategy. You should handle locking by yourself.
166
+ # config.lock_strategy = :failed_attempts
167
+
168
+ # Defines which key will be used when locking and unlocking an account
169
+ # config.unlock_keys = [ :email ]
170
+
171
+ # Defines which strategy will be used to unlock an account.
172
+ # :email = Sends an unlock link to the user email
173
+ # :time = Re-enables login after a certain amount of time (see :unlock_in below)
174
+ # :both = Enables both strategies
175
+ # :none = No unlock strategy. You should handle unlocking by yourself.
176
+ # config.unlock_strategy = :both
177
+
178
+ # Number of authentication tries before locking an account if lock_strategy
179
+ # is failed attempts.
180
+ # config.maximum_attempts = 20
181
+
182
+ # Time interval to unlock the account if :time is enabled as unlock_strategy.
183
+ # config.unlock_in = 1.hour
184
+
185
+ # Warn on the last attempt before the account is locked.
186
+ # config.last_attempt_warning = true
187
+
188
+ # ==> Configuration for :recoverable
189
+ #
190
+ # Defines which key will be used when recovering the password for an account
191
+ # config.reset_password_keys = [ :email ]
192
+
193
+ # Time interval you can reset your password with a reset password key.
194
+ # Don't put a too small interval or your users won't have the time to
195
+ # change their passwords.
196
+ config.reset_password_within = 6.hours
197
+
198
+ # ==> Configuration for :encryptable
199
+ # Allow you to use another encryption algorithm besides bcrypt (default). You can use
200
+ # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
201
+ # :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
202
+ # and :restful_authentication_sha1 (then you should set stretches to 10, and copy
203
+ # REST_AUTH_SITE_KEY to pepper).
204
+ #
205
+ # Require the `devise-encryptable` gem when using anything other than bcrypt
206
+ # config.encryptor = :sha512
207
+
208
+ # ==> Scopes configuration
209
+ # Turn scoped views on. Before rendering "sessions/new", it will first check for
210
+ # "users/sessions/new". It's turned off by default because it's slower if you
211
+ # are using only default views.
212
+ # config.scoped_views = false
213
+
214
+ # Configure the default scope given to Warden. By default it's the first
215
+ # devise role declared in your routes (usually :user).
216
+ # config.default_scope = :user
217
+
218
+ # Set this configuration to false if you want /users/sign_out to sign out
219
+ # only the current scope. By default, Devise signs out all scopes.
220
+ # config.sign_out_all_scopes = true
221
+
222
+ # ==> Navigation configuration
223
+ # Lists the formats that should be treated as navigational. Formats like
224
+ # :html, should redirect to the sign in page when the user does not have
225
+ # access, but formats like :xml or :json, should return 401.
226
+ #
227
+ # If you have any extra navigational formats, like :iphone or :mobile, you
228
+ # should add them to the navigational formats lists.
229
+ #
230
+ # The "*/*" below is required to match Internet Explorer requests.
231
+ # config.navigational_formats = ['*/*', :html]
232
+
233
+ # The default HTTP method used to sign out a resource. Default is :delete.
234
+ config.sign_out_via = :delete
235
+
236
+ # ==> OmniAuth
237
+ # Add a new OmniAuth provider. Check the wiki for more information on setting
238
+ # up on your models and hooks.
239
+ # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
240
+
241
+ # ==> Warden configuration
242
+ # If you want to use other strategies, that are not supported by Devise, or
243
+ # change the failure app, you can configure them inside the config.warden block.
244
+ #
245
+ # config.warden do |manager|
246
+ # manager.intercept_401 = false
247
+ # manager.default_strategies(scope: :user).unshift :some_external_strategy
248
+ # end
249
+
250
+ # ==> Mountable engine configurations
251
+ # When using Devise inside an engine, let's call it `MyEngine`, and this engine
252
+ # is mountable, there are some extra configurations to be taken into account.
253
+ # The following options are available, assuming the engine is mounted as:
254
+ #
255
+ # mount MyEngine, at: '/my_engine'
256
+ #
257
+ # The router that invoked `devise_for`, in the example above, would be:
258
+ # config.router_name = :my_engine
259
+ #
260
+ # When using OmniAuth, Devise cannot automatically set OmniAuth path,
261
+ # so you need to do it manually. For the users scope, it would be:
262
+ # config.omniauth_path_prefix = '/my_engine/users/auth'
263
+ end