cloudfoundry-devise 1.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (210) hide show
  1. data/.gitignore +12 -0
  2. data/.travis.yml +13 -0
  3. data/CHANGELOG.rdoc +755 -0
  4. data/Gemfile +35 -0
  5. data/MIT-LICENSE +20 -0
  6. data/README.rdoc +366 -0
  7. data/Rakefile +34 -0
  8. data/app/controllers/devise/confirmations_controller.rb +46 -0
  9. data/app/controllers/devise/omniauth_callbacks_controller.rb +26 -0
  10. data/app/controllers/devise/passwords_controller.rb +50 -0
  11. data/app/controllers/devise/registrations_controller.rb +114 -0
  12. data/app/controllers/devise/sessions_controller.rb +49 -0
  13. data/app/controllers/devise/unlocks_controller.rb +34 -0
  14. data/app/helpers/devise_helper.rb +25 -0
  15. data/app/mailers/devise/mailer.rb +15 -0
  16. data/app/views/devise/confirmations/new.html.erb +12 -0
  17. data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
  18. data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  19. data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  20. data/app/views/devise/passwords/edit.html.erb +16 -0
  21. data/app/views/devise/passwords/new.html.erb +12 -0
  22. data/app/views/devise/registrations/edit.html.erb +25 -0
  23. data/app/views/devise/registrations/new.html.erb +18 -0
  24. data/app/views/devise/sessions/new.html.erb +17 -0
  25. data/app/views/devise/shared/_links.erb +25 -0
  26. data/app/views/devise/unlocks/new.html.erb +12 -0
  27. data/cloudfoundry-devise.gemspec +25 -0
  28. data/config/locales/en.yml +59 -0
  29. data/lib/devise.rb +453 -0
  30. data/lib/devise/controllers/helpers.rb +260 -0
  31. data/lib/devise/controllers/internal_helpers.rb +161 -0
  32. data/lib/devise/controllers/rememberable.rb +52 -0
  33. data/lib/devise/controllers/scoped_views.rb +33 -0
  34. data/lib/devise/controllers/shared_helpers.rb +26 -0
  35. data/lib/devise/controllers/url_helpers.rb +53 -0
  36. data/lib/devise/delegator.rb +16 -0
  37. data/lib/devise/encryptors/authlogic_sha512.rb +19 -0
  38. data/lib/devise/encryptors/base.rb +20 -0
  39. data/lib/devise/encryptors/clearance_sha1.rb +17 -0
  40. data/lib/devise/encryptors/restful_authentication_sha1.rb +22 -0
  41. data/lib/devise/encryptors/sha1.rb +25 -0
  42. data/lib/devise/encryptors/sha512.rb +25 -0
  43. data/lib/devise/failure_app.rb +149 -0
  44. data/lib/devise/hooks/activatable.rb +11 -0
  45. data/lib/devise/hooks/forgetable.rb +9 -0
  46. data/lib/devise/hooks/rememberable.rb +6 -0
  47. data/lib/devise/hooks/timeoutable.rb +24 -0
  48. data/lib/devise/hooks/trackable.rb +9 -0
  49. data/lib/devise/mailers/helpers.rb +86 -0
  50. data/lib/devise/mapping.rb +175 -0
  51. data/lib/devise/models.rb +91 -0
  52. data/lib/devise/models/authenticatable.rb +181 -0
  53. data/lib/devise/models/confirmable.rb +220 -0
  54. data/lib/devise/models/database_authenticatable.rb +122 -0
  55. data/lib/devise/models/encryptable.rb +72 -0
  56. data/lib/devise/models/lockable.rb +169 -0
  57. data/lib/devise/models/omniauthable.rb +23 -0
  58. data/lib/devise/models/recoverable.rb +136 -0
  59. data/lib/devise/models/registerable.rb +21 -0
  60. data/lib/devise/models/rememberable.rb +114 -0
  61. data/lib/devise/models/serializable.rb +43 -0
  62. data/lib/devise/models/timeoutable.rb +45 -0
  63. data/lib/devise/models/token_authenticatable.rb +72 -0
  64. data/lib/devise/models/trackable.rb +30 -0
  65. data/lib/devise/models/validatable.rb +62 -0
  66. data/lib/devise/modules.rb +30 -0
  67. data/lib/devise/omniauth.rb +28 -0
  68. data/lib/devise/omniauth/config.rb +45 -0
  69. data/lib/devise/omniauth/url_helpers.rb +33 -0
  70. data/lib/devise/orm/active_record.rb +44 -0
  71. data/lib/devise/orm/mongoid.rb +31 -0
  72. data/lib/devise/param_filter.rb +41 -0
  73. data/lib/devise/path_checker.rb +18 -0
  74. data/lib/devise/rails.rb +73 -0
  75. data/lib/devise/rails/routes.rb +385 -0
  76. data/lib/devise/rails/warden_compat.rb +120 -0
  77. data/lib/devise/schema.rb +109 -0
  78. data/lib/devise/strategies/authenticatable.rb +155 -0
  79. data/lib/devise/strategies/base.rb +15 -0
  80. data/lib/devise/strategies/database_authenticatable.rb +21 -0
  81. data/lib/devise/strategies/rememberable.rb +53 -0
  82. data/lib/devise/strategies/token_authenticatable.rb +57 -0
  83. data/lib/devise/test_helpers.rb +90 -0
  84. data/lib/devise/version.rb +3 -0
  85. data/lib/generators/active_record/devise_generator.rb +71 -0
  86. data/lib/generators/active_record/templates/migration.rb +29 -0
  87. data/lib/generators/active_record/templates/migration_existing.rb +26 -0
  88. data/lib/generators/devise/devise_generator.rb +22 -0
  89. data/lib/generators/devise/install_generator.rb +24 -0
  90. data/lib/generators/devise/orm_helpers.rb +31 -0
  91. data/lib/generators/devise/views_generator.rb +98 -0
  92. data/lib/generators/mongoid/devise_generator.rb +60 -0
  93. data/lib/generators/templates/README +32 -0
  94. data/lib/generators/templates/devise.rb +215 -0
  95. data/lib/generators/templates/markerb/confirmation_instructions.markerb +5 -0
  96. data/lib/generators/templates/markerb/reset_password_instructions.markerb +8 -0
  97. data/lib/generators/templates/markerb/unlock_instructions.markerb +7 -0
  98. data/lib/generators/templates/simple_form_for/confirmations/new.html.erb +15 -0
  99. data/lib/generators/templates/simple_form_for/passwords/edit.html.erb +19 -0
  100. data/lib/generators/templates/simple_form_for/passwords/new.html.erb +15 -0
  101. data/lib/generators/templates/simple_form_for/registrations/edit.html.erb +22 -0
  102. data/lib/generators/templates/simple_form_for/registrations/new.html.erb +17 -0
  103. data/lib/generators/templates/simple_form_for/sessions/new.html.erb +15 -0
  104. data/lib/generators/templates/simple_form_for/unlocks/new.html.erb +15 -0
  105. data/test/controllers/helpers_test.rb +254 -0
  106. data/test/controllers/internal_helpers_test.rb +96 -0
  107. data/test/controllers/sessions_controller_test.rb +16 -0
  108. data/test/controllers/url_helpers_test.rb +59 -0
  109. data/test/delegator_test.rb +19 -0
  110. data/test/devise_test.rb +72 -0
  111. data/test/encryptors_test.rb +30 -0
  112. data/test/failure_app_test.rb +207 -0
  113. data/test/generators/active_record_generator_test.rb +47 -0
  114. data/test/generators/devise_generator_test.rb +39 -0
  115. data/test/generators/install_generator_test.rb +13 -0
  116. data/test/generators/mongoid_generator_test.rb +23 -0
  117. data/test/generators/views_generator_test.rb +52 -0
  118. data/test/helpers/devise_helper_test.rb +51 -0
  119. data/test/indifferent_hash.rb +33 -0
  120. data/test/integration/authenticatable_test.rb +590 -0
  121. data/test/integration/confirmable_test.rb +262 -0
  122. data/test/integration/database_authenticatable_test.rb +82 -0
  123. data/test/integration/http_authenticatable_test.rb +82 -0
  124. data/test/integration/lockable_test.rb +212 -0
  125. data/test/integration/omniauthable_test.rb +133 -0
  126. data/test/integration/recoverable_test.rb +287 -0
  127. data/test/integration/registerable_test.rb +335 -0
  128. data/test/integration/rememberable_test.rb +158 -0
  129. data/test/integration/timeoutable_test.rb +98 -0
  130. data/test/integration/token_authenticatable_test.rb +148 -0
  131. data/test/integration/trackable_test.rb +92 -0
  132. data/test/mailers/confirmation_instructions_test.rb +95 -0
  133. data/test/mailers/reset_password_instructions_test.rb +83 -0
  134. data/test/mailers/unlock_instructions_test.rb +77 -0
  135. data/test/mapping_test.rb +128 -0
  136. data/test/models/confirmable_test.rb +334 -0
  137. data/test/models/database_authenticatable_test.rb +167 -0
  138. data/test/models/encryptable_test.rb +67 -0
  139. data/test/models/lockable_test.rb +225 -0
  140. data/test/models/recoverable_test.rb +198 -0
  141. data/test/models/rememberable_test.rb +168 -0
  142. data/test/models/serializable_test.rb +38 -0
  143. data/test/models/timeoutable_test.rb +42 -0
  144. data/test/models/token_authenticatable_test.rb +49 -0
  145. data/test/models/trackable_test.rb +5 -0
  146. data/test/models/validatable_test.rb +113 -0
  147. data/test/models_test.rb +109 -0
  148. data/test/omniauth/config_test.rb +57 -0
  149. data/test/omniauth/url_helpers_test.rb +58 -0
  150. data/test/orm/active_record.rb +9 -0
  151. data/test/orm/mongoid.rb +14 -0
  152. data/test/rails_app/Rakefile +10 -0
  153. data/test/rails_app/app/active_record/admin.rb +6 -0
  154. data/test/rails_app/app/active_record/shim.rb +2 -0
  155. data/test/rails_app/app/active_record/user.rb +6 -0
  156. data/test/rails_app/app/controllers/admins/sessions_controller.rb +6 -0
  157. data/test/rails_app/app/controllers/admins_controller.rb +6 -0
  158. data/test/rails_app/app/controllers/application_controller.rb +8 -0
  159. data/test/rails_app/app/controllers/home_controller.rb +25 -0
  160. data/test/rails_app/app/controllers/publisher/registrations_controller.rb +2 -0
  161. data/test/rails_app/app/controllers/publisher/sessions_controller.rb +2 -0
  162. data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +14 -0
  163. data/test/rails_app/app/controllers/users_controller.rb +23 -0
  164. data/test/rails_app/app/helpers/application_helper.rb +3 -0
  165. data/test/rails_app/app/mailers/users/mailer.rb +3 -0
  166. data/test/rails_app/app/mongoid/admin.rb +24 -0
  167. data/test/rails_app/app/mongoid/shim.rb +24 -0
  168. data/test/rails_app/app/mongoid/user.rb +45 -0
  169. data/test/rails_app/app/views/admins/index.html.erb +1 -0
  170. data/test/rails_app/app/views/admins/sessions/new.html.erb +2 -0
  171. data/test/rails_app/app/views/home/admin_dashboard.html.erb +1 -0
  172. data/test/rails_app/app/views/home/index.html.erb +1 -0
  173. data/test/rails_app/app/views/home/join.html.erb +1 -0
  174. data/test/rails_app/app/views/home/private.html.erb +1 -0
  175. data/test/rails_app/app/views/home/user_dashboard.html.erb +1 -0
  176. data/test/rails_app/app/views/layouts/application.html.erb +24 -0
  177. data/test/rails_app/app/views/users/index.html.erb +1 -0
  178. data/test/rails_app/app/views/users/mailer/confirmation_instructions.erb +1 -0
  179. data/test/rails_app/app/views/users/sessions/new.html.erb +1 -0
  180. data/test/rails_app/config.ru +4 -0
  181. data/test/rails_app/config/application.rb +41 -0
  182. data/test/rails_app/config/boot.rb +8 -0
  183. data/test/rails_app/config/database.yml +18 -0
  184. data/test/rails_app/config/environment.rb +5 -0
  185. data/test/rails_app/config/environments/development.rb +18 -0
  186. data/test/rails_app/config/environments/production.rb +33 -0
  187. data/test/rails_app/config/environments/test.rb +33 -0
  188. data/test/rails_app/config/initializers/backtrace_silencers.rb +7 -0
  189. data/test/rails_app/config/initializers/devise.rb +197 -0
  190. data/test/rails_app/config/initializers/inflections.rb +2 -0
  191. data/test/rails_app/config/initializers/secret_token.rb +2 -0
  192. data/test/rails_app/config/routes.rb +87 -0
  193. data/test/rails_app/db/migrate/20100401102949_create_tables.rb +71 -0
  194. data/test/rails_app/db/schema.rb +52 -0
  195. data/test/rails_app/lib/shared_admin.rb +10 -0
  196. data/test/rails_app/lib/shared_user.rb +26 -0
  197. data/test/rails_app/public/404.html +26 -0
  198. data/test/rails_app/public/422.html +26 -0
  199. data/test/rails_app/public/500.html +26 -0
  200. data/test/rails_app/public/favicon.ico +0 -0
  201. data/test/rails_app/script/rails +10 -0
  202. data/test/routes_test.rb +240 -0
  203. data/test/support/assertions.rb +27 -0
  204. data/test/support/helpers.rb +109 -0
  205. data/test/support/integration.rb +88 -0
  206. data/test/support/locale/en.yml +4 -0
  207. data/test/support/webrat/integrations/rails.rb +24 -0
  208. data/test/test_helper.rb +27 -0
  209. data/test/test_helpers_test.rb +134 -0
  210. metadata +295 -0
@@ -0,0 +1,3 @@
1
+ module Devise
2
+ VERSION = "1.5.2".freeze
3
+ end
@@ -0,0 +1,71 @@
1
+ require 'rails/generators/active_record'
2
+ require 'generators/devise/orm_helpers'
3
+
4
+ module ActiveRecord
5
+ module Generators
6
+ class DeviseGenerator < ActiveRecord::Generators::Base
7
+ argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
8
+
9
+ include Devise::Generators::OrmHelpers
10
+ source_root File.expand_path("../templates", __FILE__)
11
+
12
+ def copy_devise_migration
13
+ if (behavior == :invoke && model_exists?) || (behavior == :revoke && migration_exists?(table_name))
14
+ migration_template "migration_existing.rb", "db/migrate/add_devise_to_#{table_name}"
15
+ else
16
+ migration_template "migration.rb", "db/migrate/devise_create_#{table_name}"
17
+ end
18
+ end
19
+
20
+ def generate_model
21
+ invoke "active_record:model", [name], :migration => false unless model_exists? && behavior == :invoke
22
+ end
23
+
24
+ def inject_devise_content
25
+ inject_into_class(model_path, class_name, model_contents + <<CONTENT) if model_exists?
26
+ # Setup accessible (or protected) attributes for your model
27
+ attr_accessible :email, :password, :password_confirmation, :remember_me
28
+ CONTENT
29
+ end
30
+
31
+ def migration_data
32
+ <<RUBY
33
+ ## Database authenticatable
34
+ t.string :email, :null => false, :default => ""
35
+ t.string :encrypted_password, :null => false, :default => ""
36
+
37
+ ## Recoverable
38
+ t.string :reset_password_token
39
+ t.datetime :reset_password_sent_at
40
+
41
+ ## Rememberable
42
+ t.datetime :remember_created_at
43
+
44
+ ## Trackable
45
+ t.integer :sign_in_count, :default => 0
46
+ t.datetime :current_sign_in_at
47
+ t.datetime :last_sign_in_at
48
+ t.string :current_sign_in_ip
49
+ t.string :last_sign_in_ip
50
+
51
+ ## Encryptable
52
+ # t.string :password_salt
53
+
54
+ ## Confirmable
55
+ # t.string :confirmation_token
56
+ # t.datetime :confirmed_at
57
+ # t.datetime :confirmation_sent_at
58
+ # t.string :unconfirmed_email # Only if using reconfirmable
59
+
60
+ ## Lockable
61
+ # t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
62
+ # t.string :unlock_token # Only if unlock strategy is :email or :both
63
+ # t.datetime :locked_at
64
+
65
+ # Token authenticatable
66
+ # t.string :authentication_token
67
+ RUBY
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,29 @@
1
+ class DeviseCreate<%= table_name.camelize %> < ActiveRecord::Migration
2
+ <% if ::Rails::VERSION::MAJOR == 3 && ::Rails::VERSION::MINOR >= 1 -%>
3
+ def change
4
+ <% else -%>
5
+ def self.up
6
+ <% end -%>
7
+ create_table(:<%= table_name %>) do |t|
8
+ <%= migration_data -%>
9
+
10
+ <% attributes.each do |attribute| -%>
11
+ t.<%= attribute.type %> :<%= attribute.name %>
12
+ <% end -%>
13
+
14
+ t.timestamps
15
+ end
16
+
17
+ add_index :<%= table_name %>, :email, :unique => true
18
+ add_index :<%= table_name %>, :reset_password_token, :unique => true
19
+ # add_index :<%= table_name %>, :confirmation_token, :unique => true
20
+ # add_index :<%= table_name %>, :unlock_token, :unique => true
21
+ # add_index :<%= table_name %>, :authentication_token, :unique => true
22
+ end
23
+
24
+ <% unless ::Rails::VERSION::MAJOR == 3 && ::Rails::VERSION::MINOR >= 1 -%>
25
+ def self.down
26
+ drop_table :<%= table_name %>
27
+ end
28
+ <% end -%>
29
+ end
@@ -0,0 +1,26 @@
1
+ class AddDeviseTo<%= table_name.camelize %> < ActiveRecord::Migration
2
+ def self.up
3
+ change_table(:<%= table_name %>) do |t|
4
+ <%= migration_data -%>
5
+
6
+ <% attributes.each do |attribute| -%>
7
+ t.<%= attribute.type %> :<%= attribute.name %>
8
+ <% end -%>
9
+
10
+ # Uncomment below if timestamps were not included in your original model.
11
+ # t.timestamps
12
+ end
13
+
14
+ add_index :<%= table_name %>, :email, :unique => true
15
+ add_index :<%= table_name %>, :reset_password_token, :unique => true
16
+ # add_index :<%= table_name %>, :confirmation_token, :unique => true
17
+ # add_index :<%= table_name %>, :unlock_token, :unique => true
18
+ # add_index :<%= table_name %>, :authentication_token, :unique => true
19
+ end
20
+
21
+ def self.down
22
+ # By default, we don't want to make any assumption about how to roll back a migration when your
23
+ # model already existed. Please edit below which fields you would like to remove in this migration.
24
+ raise ActiveRecord::IrreversibleMigration
25
+ end
26
+ end
@@ -0,0 +1,22 @@
1
+ module Devise
2
+ module Generators
3
+ class DeviseGenerator < Rails::Generators::NamedBase
4
+ namespace "devise"
5
+ source_root File.expand_path("../templates", __FILE__)
6
+
7
+ desc "Generates a model with the given NAME (if one does not exist) with devise " <<
8
+ "configuration plus a migration file and devise routes."
9
+
10
+ hook_for :orm
11
+
12
+ class_option :routes, :desc => "Generate routes", :type => :boolean, :default => true
13
+
14
+ def add_devise_routes
15
+ devise_route = "devise_for :#{plural_name}"
16
+ devise_route << %Q(, :class_name => "#{class_name}") if class_name.include?("::")
17
+ devise_route << %Q(, :skip => :all) unless options.routes?
18
+ route devise_route
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,24 @@
1
+ require 'securerandom'
2
+
3
+ module Devise
4
+ module Generators
5
+ class InstallGenerator < Rails::Generators::Base
6
+ source_root File.expand_path("../../templates", __FILE__)
7
+
8
+ desc "Creates a Devise initializer and copy locale files to your application."
9
+ class_option :orm
10
+
11
+ def copy_initializer
12
+ template "devise.rb", "config/initializers/devise.rb"
13
+ end
14
+
15
+ def copy_locale
16
+ copy_file "../../../config/locales/en.yml", "config/locales/devise.en.yml"
17
+ end
18
+
19
+ def show_readme
20
+ readme "README" if behavior == :invoke
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,31 @@
1
+ module Devise
2
+ module Generators
3
+ module OrmHelpers
4
+ def model_contents
5
+ <<-CONTENT
6
+ # Include default devise modules. Others available are:
7
+ # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
8
+ devise :database_authenticatable, :registerable,
9
+ :recoverable, :rememberable, :trackable, :validatable
10
+
11
+ CONTENT
12
+ end
13
+
14
+ def model_exists?
15
+ File.exists?(File.join(destination_root, model_path))
16
+ end
17
+
18
+ def migration_exists?(table_name)
19
+ Dir.glob("#{File.join(destination_root, migration_path)}/[0-9]*_*.rb").grep(/\d+_add_devise_to_#{table_name}.rb$/).first
20
+ end
21
+
22
+ def migration_path
23
+ @migration_path ||= File.join("db", "migrate")
24
+ end
25
+
26
+ def model_path
27
+ @model_path ||= File.join("app", "models", "#{file_path}.rb")
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,98 @@
1
+ module Devise
2
+ module Generators
3
+ # Include this module in your generator to generate Devise views.
4
+ # `copy_views` is the main method and by default copies all views
5
+ # with forms.
6
+ module ViewPathTemplates #:nodoc:
7
+ extend ActiveSupport::Concern
8
+
9
+ included do
10
+ argument :scope, :required => false, :default => nil,
11
+ :desc => "The scope to copy views to"
12
+
13
+ public_task :copy_views
14
+ end
15
+
16
+ def copy_views
17
+ view_directory :confirmations
18
+ view_directory :passwords
19
+ view_directory :registrations
20
+ view_directory :sessions
21
+ view_directory :unlocks
22
+ end
23
+
24
+ protected
25
+
26
+ def view_directory(name, _target_path = nil)
27
+ directory name.to_s, _target_path || "#{target_path}/#{name}"
28
+ end
29
+
30
+ def target_path
31
+ @target_path ||= "app/views/#{scope || :devise}"
32
+ end
33
+ end
34
+
35
+ class SharedViewsGenerator < Rails::Generators::Base #:nodoc:
36
+ include ViewPathTemplates
37
+ source_root File.expand_path("../../../../app/views/devise", __FILE__)
38
+ desc "Copies shared Devise views to your application."
39
+
40
+ # Override copy_views to just copy mailer and shared.
41
+ def copy_views
42
+ view_directory :shared
43
+ end
44
+ end
45
+
46
+ class FormForGenerator < Rails::Generators::Base #:nodoc:
47
+ include ViewPathTemplates
48
+ source_root File.expand_path("../../../../app/views/devise", __FILE__)
49
+ desc "Copies default Devise views to your application."
50
+ end
51
+
52
+ class SimpleFormForGenerator < Rails::Generators::Base #:nodoc:
53
+ include ViewPathTemplates
54
+ source_root File.expand_path("../../templates/simple_form_for", __FILE__)
55
+ desc "Copies simple form enabled views to your application."
56
+ end
57
+
58
+ class ErbGenerator < Rails::Generators::Base #:nodoc:
59
+ include ViewPathTemplates
60
+ source_root File.expand_path("../../../../app/views/devise", __FILE__)
61
+ desc "Copies Devise mail erb views to your application."
62
+
63
+ def copy_views
64
+ view_directory :mailer
65
+ end
66
+ end
67
+
68
+ class MarkerbGenerator < Rails::Generators::Base #:nodoc:
69
+ include ViewPathTemplates
70
+ source_root File.expand_path("../../templates", __FILE__)
71
+ desc "Copies Devise mail markerb views to your application."
72
+
73
+ def copy_views
74
+ view_directory :markerb, target_path
75
+ end
76
+
77
+ def target_path
78
+ "app/views/#{scope || :devise}/mailer"
79
+ end
80
+ end
81
+
82
+ class ViewsGenerator < Rails::Generators::Base
83
+ desc "Copies Devise views to your application."
84
+
85
+ argument :scope, :required => false, :default => nil,
86
+ :desc => "The scope to copy views to"
87
+
88
+ invoke SharedViewsGenerator
89
+ hook_for :form_builder, :aliases => "-b",
90
+ :desc => "Form builder to be used",
91
+ :default => defined?(SimpleForm) ? "simple_form_for" : "form_for"
92
+
93
+ hook_for :markerb, :desc => "Generate markerb instead of erb mail views",
94
+ :default => defined?(Markerb) ? :markerb : :erb,
95
+ :type => :boolean
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,60 @@
1
+ require 'generators/devise/orm_helpers'
2
+
3
+ module Mongoid
4
+ module Generators
5
+ class DeviseGenerator < Rails::Generators::NamedBase
6
+ include Devise::Generators::OrmHelpers
7
+
8
+ def generate_model
9
+ invoke "mongoid:model", [name] unless model_exists? && behavior == :invoke
10
+ end
11
+
12
+ def inject_field_types
13
+ inject_into_file model_path, migration_data, :after => "include Mongoid::Document\n" if model_exists?
14
+ end
15
+
16
+ def inject_devise_content
17
+ inject_into_file model_path, model_contents, :after => "include Mongoid::Document\n" if model_exists?
18
+ end
19
+
20
+ def migration_data
21
+ <<RUBY
22
+ ## Database authenticatable
23
+ field :email, :type => String, :null => false, :default => ""
24
+ field :encrypted_password, :type => String, :null => false, :default => ""
25
+
26
+ ## Recoverable
27
+ field :reset_password_token, :type => String
28
+ field :reset_password_sent_at, :type => Time
29
+
30
+ ## Rememberable
31
+ field :remember_created_at, :type => Time
32
+
33
+ ## Trackable
34
+ field :sign_in_count, :type => Integer, :default => 0
35
+ field :current_sign_in_at, :type => Time
36
+ field :last_sign_in_at, :type => Time
37
+ field :current_sign_in_ip, :type => String
38
+ field :last_sign_in_ip, :type => String
39
+
40
+ ## Encryptable
41
+ # field :password_salt, :type => String
42
+
43
+ ## Confirmable
44
+ # field :confirmation_token, :type => String
45
+ # field :confirmed_at, :type => Time
46
+ # field :confirmation_sent_at, :type => Time
47
+ # field :unconfirmed_email, :type => String # Only if using reconfirmable
48
+
49
+ ## Lockable
50
+ # field :failed_attempts, :type => Integer, :default => 0 # Only if lock strategy is :failed_attempts
51
+ # field :unlock_token, :type => String # Only if unlock strategy is :email or :both
52
+ # field :locked_at, :type => Time
53
+
54
+ ## Token authenticatable
55
+ # field :authentication_token, :type => String
56
+ RUBY
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,32 @@
1
+
2
+ ===============================================================================
3
+
4
+ Some setup you must do manually if you haven't yet:
5
+
6
+ 1. Setup default url options for your specific environment. Here is an
7
+ example of development environment:
8
+
9
+ config.action_mailer.default_url_options = { :host => 'localhost:3000' }
10
+
11
+ This is a required Rails configuration. In production it must be the
12
+ actual host of your application
13
+
14
+ 2. Ensure you have defined root_url to *something* in your config/routes.rb.
15
+ For example:
16
+
17
+ root :to => "home#index"
18
+
19
+ 3. Ensure you have flash messages in app/views/layouts/application.html.erb.
20
+ For example:
21
+
22
+ <p class="notice"><%= notice %></p>
23
+ <p class="alert"><%= alert %></p>
24
+
25
+ 4. If you are deploying Rails 3.1 on Heroku, you may want to set:
26
+
27
+ config.assets.initialize_on_precompile = false
28
+
29
+ On config/application.rb forcing your application to not access the DB
30
+ or load models when precompiling your assets.
31
+
32
+ ===============================================================================
@@ -0,0 +1,215 @@
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
+ # ==> Mailer Configuration
5
+ # Configure the e-mail address which will be shown in Devise::Mailer,
6
+ # note that it will be overwritten if you use your own mailer class with default "from" parameter.
7
+ config.mailer_sender = "please-change-me-at-config-initializers-devise@example.com"
8
+
9
+ # Configure the class responsible to send e-mails.
10
+ # config.mailer = "Devise::Mailer"
11
+
12
+ # Automatically apply schema changes in tableless databases
13
+ config.apply_schema = false
14
+
15
+ # ==> ORM configuration
16
+ # Load and configure the ORM. Supports :active_record (default) and
17
+ # :mongoid (bson_ext recommended) by default. Other ORMs may be
18
+ # available as additional gems.
19
+ require 'devise/orm/<%= options[:orm] %>'
20
+
21
+ # ==> Configuration for any authentication mechanism
22
+ # Configure which keys are used when authenticating a user. The default is
23
+ # just :email. You can configure it to use [:username, :subdomain], so for
24
+ # authenticating a user, both parameters are required. Remember that those
25
+ # parameters are used only when authenticating and not when retrieving from
26
+ # session. If you need permissions, you should implement that in a before filter.
27
+ # You can also supply a hash where the value is a boolean determining whether
28
+ # or not authentication should be aborted when the value is not present.
29
+ # config.authentication_keys = [ :email ]
30
+
31
+ # Configure parameters from the request object used for authentication. Each entry
32
+ # given should be a request method and it will automatically be passed to the
33
+ # find_for_authentication method and considered in your model lookup. For instance,
34
+ # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
35
+ # The same considerations mentioned for authentication_keys also apply to request_keys.
36
+ # config.request_keys = []
37
+
38
+ # Configure which authentication keys should be case-insensitive.
39
+ # These keys will be downcased upon creating or modifying a user and when used
40
+ # to authenticate or find a user. Default is :email.
41
+ config.case_insensitive_keys = [ :email ]
42
+
43
+ # Configure which authentication keys should have whitespace stripped.
44
+ # These keys will have whitespace before and after removed upon creating or
45
+ # modifying a user and when used to authenticate or find a user. Default is :email.
46
+ config.strip_whitespace_keys = [ :email ]
47
+
48
+ # Tell if authentication through request.params is enabled. True by default.
49
+ # config.params_authenticatable = true
50
+
51
+ # Tell if authentication through HTTP Basic Auth is enabled. False by default.
52
+ # config.http_authenticatable = false
53
+
54
+ # If http headers should be returned for AJAX requests. True by default.
55
+ # config.http_authenticatable_on_xhr = true
56
+
57
+ # The realm used in Http Basic Authentication. "Application" by default.
58
+ # config.http_authentication_realm = "Application"
59
+
60
+ # It will change confirmation, password recovery and other workflows
61
+ # to behave the same regardless if the e-mail provided was right or wrong.
62
+ # Does not affect registerable.
63
+ # config.paranoid = true
64
+
65
+ # ==> Configuration for :database_authenticatable
66
+ # For bcrypt, this is the cost for hashing the password and defaults to 10. If
67
+ # using other encryptors, it sets how many times you want the password re-encrypted.
68
+ #
69
+ # Limiting the stretches to just one in testing will increase the performance of
70
+ # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
71
+ # a value less than 10 in other environments.
72
+ config.stretches = Rails.env.test? ? 1 : 10
73
+
74
+ # Setup a pepper to generate the encrypted password.
75
+ # config.pepper = <%= SecureRandom.hex(64).inspect %>
76
+
77
+ # ==> Configuration for :confirmable
78
+ # A period that the user is allowed to access the website even without
79
+ # confirming his account. For instance, if set to 2.days, the user will be
80
+ # able to access the website for two days without confirming his account,
81
+ # access will be blocked just in the third day. Default is 0.days, meaning
82
+ # the user cannot access the website without confirming his account.
83
+ # config.confirm_within = 2.days
84
+
85
+ # If true, requires any email changes to be confirmed (exctly the same way as
86
+ # initial account confirmation) to be applied. Requires additional unconfirmed_email
87
+ # db field (see migrations). Until confirmed new email is stored in
88
+ # unconfirmed email column, and copied to email column on successful confirmation.
89
+ config.reconfirmable = true
90
+
91
+ # Defines which key will be used when confirming an account
92
+ # config.confirmation_keys = [ :email ]
93
+
94
+ # ==> Configuration for :rememberable
95
+ # The time the user will be remembered without asking for credentials again.
96
+ # config.remember_for = 2.weeks
97
+
98
+ # If true, extends the user's remember period when remembered via cookie.
99
+ # config.extend_remember_period = false
100
+
101
+ # If true, uses the password salt as remember token. This should be turned
102
+ # to false if you are not using database authenticatable.
103
+ config.use_salt_as_remember_token = true
104
+
105
+ # Options to be passed to the created cookie. For instance, you can set
106
+ # :secure => true in order to force SSL only cookies.
107
+ # config.cookie_options = {}
108
+
109
+ # ==> Configuration for :validatable
110
+ # Range for password length. Default is 6..128.
111
+ # config.password_length = 6..128
112
+
113
+ # Email regex used to validate email formats. It simply asserts that
114
+ # an one (and only one) @ exists in the given string. This is mainly
115
+ # to give user feedback and not to assert the e-mail validity.
116
+ # config.email_regexp = /\A[^@]+@[^@]+\z/
117
+
118
+ # ==> Configuration for :timeoutable
119
+ # The time you want to timeout the user session without activity. After this
120
+ # time the user will be asked for credentials again. Default is 30 minutes.
121
+ # config.timeout_in = 30.minutes
122
+
123
+ # ==> Configuration for :lockable
124
+ # Defines which strategy will be used to lock an account.
125
+ # :failed_attempts = Locks an account after a number of failed attempts to sign in.
126
+ # :none = No lock strategy. You should handle locking by yourself.
127
+ # config.lock_strategy = :failed_attempts
128
+
129
+ # Defines which key will be used when locking and unlocking an account
130
+ # config.unlock_keys = [ :email ]
131
+
132
+ # Defines which strategy will be used to unlock an account.
133
+ # :email = Sends an unlock link to the user email
134
+ # :time = Re-enables login after a certain amount of time (see :unlock_in below)
135
+ # :both = Enables both strategies
136
+ # :none = No unlock strategy. You should handle unlocking by yourself.
137
+ # config.unlock_strategy = :both
138
+
139
+ # Number of authentication tries before locking an account if lock_strategy
140
+ # is failed attempts.
141
+ # config.maximum_attempts = 20
142
+
143
+ # Time interval to unlock the account if :time is enabled as unlock_strategy.
144
+ # config.unlock_in = 1.hour
145
+
146
+ # ==> Configuration for :recoverable
147
+ #
148
+ # Defines which key will be used when recovering the password for an account
149
+ # config.reset_password_keys = [ :email ]
150
+
151
+ # Time interval you can reset your password with a reset password key.
152
+ # Don't put a too small interval or your users won't have the time to
153
+ # change their passwords.
154
+ config.reset_password_within = 6.hours
155
+
156
+ # ==> Configuration for :encryptable
157
+ # Allow you to use another encryption algorithm besides bcrypt (default). You can use
158
+ # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
159
+ # :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
160
+ # and :restful_authentication_sha1 (then you should set stretches to 10, and copy
161
+ # REST_AUTH_SITE_KEY to pepper)
162
+ # config.encryptor = :sha512
163
+
164
+ # ==> Configuration for :token_authenticatable
165
+ # Defines name of the authentication token params key
166
+ # config.token_authentication_key = :auth_token
167
+
168
+ # If true, authentication through token does not store user in session and needs
169
+ # to be supplied on each request. Useful if you are using the token as API token.
170
+ # config.stateless_token = false
171
+
172
+ # ==> Scopes configuration
173
+ # Turn scoped views on. Before rendering "sessions/new", it will first check for
174
+ # "users/sessions/new". It's turned off by default because it's slower if you
175
+ # are using only default views.
176
+ # config.scoped_views = false
177
+
178
+ # Configure the default scope given to Warden. By default it's the first
179
+ # devise role declared in your routes (usually :user).
180
+ # config.default_scope = :user
181
+
182
+ # Configure sign_out behavior.
183
+ # Sign_out action can be scoped (i.e. /users/sign_out affects only :user scope).
184
+ # The default is true, which means any logout action will sign out all active scopes.
185
+ # config.sign_out_all_scopes = true
186
+
187
+ # ==> Navigation configuration
188
+ # Lists the formats that should be treated as navigational. Formats like
189
+ # :html, should redirect to the sign in page when the user does not have
190
+ # access, but formats like :xml or :json, should return 401.
191
+ #
192
+ # If you have any extra navigational formats, like :iphone or :mobile, you
193
+ # should add them to the navigational formats lists.
194
+ #
195
+ # The :"*/*" and "*/*" formats below is required to match Internet
196
+ # Explorer requests.
197
+ # config.navigational_formats = [:"*/*", "*/*", :html]
198
+
199
+ # The default HTTP method used to sign out a resource. Default is :delete.
200
+ config.sign_out_via = :delete
201
+
202
+ # ==> OmniAuth
203
+ # Add a new OmniAuth provider. Check the wiki for more information on setting
204
+ # up on your models and hooks.
205
+ # config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
206
+
207
+ # ==> Warden configuration
208
+ # If you want to use other strategies, that are not supported by Devise, or
209
+ # change the failure app, you can configure them inside the config.warden block.
210
+ #
211
+ # config.warden do |manager|
212
+ # manager.intercept_401 = false
213
+ # manager.default_strategies(:scope => :user).unshift :some_external_strategy
214
+ # end
215
+ end