devise 1.0.10 → 1.1.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 (176) hide show
  1. data/CHANGELOG.rdoc +62 -10
  2. data/Gemfile +23 -0
  3. data/Gemfile.lock +118 -0
  4. data/README.rdoc +116 -77
  5. data/Rakefile +4 -2
  6. data/TODO +3 -2
  7. data/app/controllers/{confirmations_controller.rb → devise/confirmations_controller.rb} +1 -1
  8. data/app/controllers/{passwords_controller.rb → devise/passwords_controller.rb} +1 -1
  9. data/app/controllers/{registrations_controller.rb → devise/registrations_controller.rb} +12 -8
  10. data/app/controllers/devise/sessions_controller.rb +23 -0
  11. data/app/controllers/{unlocks_controller.rb → devise/unlocks_controller.rb} +1 -8
  12. data/app/helpers/devise_helper.rb +17 -0
  13. data/app/mailers/devise/mailer.rb +71 -0
  14. data/app/views/devise/confirmations/new.html.erb +12 -0
  15. data/app/views/devise/passwords/edit.html.erb +16 -0
  16. data/app/views/devise/passwords/new.html.erb +12 -0
  17. data/app/views/devise/registrations/edit.html.erb +25 -0
  18. data/app/views/devise/registrations/new.html.erb +18 -0
  19. data/app/views/devise/sessions/new.html.erb +17 -0
  20. data/app/views/devise/shared/_links.erb +19 -0
  21. data/app/views/devise/unlocks/new.html.erb +12 -0
  22. data/{lib/devise → config}/locales/en.yml +16 -12
  23. data/lib/devise/controllers/helpers.rb +57 -52
  24. data/lib/devise/controllers/internal_helpers.rb +19 -50
  25. data/lib/devise/controllers/scoped_views.rb +35 -0
  26. data/lib/devise/controllers/url_helpers.rb +1 -1
  27. data/lib/devise/encryptors/authlogic_sha512.rb +0 -2
  28. data/lib/devise/encryptors/base.rb +1 -1
  29. data/lib/devise/encryptors/bcrypt.rb +2 -4
  30. data/lib/devise/encryptors/clearance_sha1.rb +0 -2
  31. data/lib/devise/encryptors/sha1.rb +6 -8
  32. data/lib/devise/encryptors/sha512.rb +6 -8
  33. data/lib/devise/failure_app.rb +76 -39
  34. data/lib/devise/hooks/activatable.rb +6 -10
  35. data/lib/devise/hooks/forgetable.rb +11 -0
  36. data/lib/devise/hooks/rememberable.rb +40 -30
  37. data/lib/devise/hooks/timeoutable.rb +7 -3
  38. data/lib/devise/hooks/trackable.rb +5 -14
  39. data/lib/devise/mapping.rb +35 -62
  40. data/lib/devise/models/authenticatable.rb +126 -0
  41. data/lib/devise/models/confirmable.rb +19 -22
  42. data/lib/devise/models/database_authenticatable.rb +26 -60
  43. data/lib/devise/models/lockable.rb +43 -28
  44. data/lib/devise/models/recoverable.rb +11 -10
  45. data/lib/devise/models/rememberable.rb +56 -26
  46. data/lib/devise/models/timeoutable.rb +1 -3
  47. data/lib/devise/models/token_authenticatable.rb +14 -43
  48. data/lib/devise/models/trackable.rb +14 -0
  49. data/lib/devise/models/validatable.rb +16 -2
  50. data/lib/devise/models.rb +16 -53
  51. data/lib/devise/modules.rb +23 -0
  52. data/lib/devise/orm/active_record.rb +10 -15
  53. data/lib/devise/orm/mongoid.rb +29 -0
  54. data/lib/devise/path_checker.rb +18 -0
  55. data/lib/devise/rails/routes.rb +232 -117
  56. data/lib/devise/rails/warden_compat.rb +18 -39
  57. data/lib/devise/rails.rb +64 -9
  58. data/lib/devise/schema.rb +47 -23
  59. data/lib/devise/strategies/authenticatable.rb +123 -0
  60. data/lib/devise/strategies/base.rb +2 -3
  61. data/lib/devise/strategies/database_authenticatable.rb +7 -22
  62. data/lib/devise/strategies/rememberable.rb +21 -7
  63. data/lib/devise/strategies/token_authenticatable.rb +31 -19
  64. data/lib/devise/test_helpers.rb +6 -6
  65. data/lib/devise/version.rb +1 -1
  66. data/lib/devise.rb +174 -157
  67. data/lib/generators/active_record/devise_generator.rb +28 -0
  68. data/{generators/devise → lib/generators/active_record}/templates/migration.rb +9 -3
  69. data/lib/generators/devise/devise_generator.rb +17 -0
  70. data/lib/generators/devise/install_generator.rb +24 -0
  71. data/lib/generators/devise/orm_helpers.rb +23 -0
  72. data/{generators/devise_install → lib/generators/devise}/templates/README +9 -7
  73. data/lib/generators/devise/templates/devise.rb +142 -0
  74. data/lib/generators/devise/views_generator.rb +63 -0
  75. data/lib/generators/devise_install_generator.rb +4 -0
  76. data/lib/generators/devise_views_generator.rb +4 -0
  77. data/lib/generators/mongoid/devise_generator.rb +17 -0
  78. data/test/controllers/helpers_test.rb +48 -19
  79. data/test/controllers/internal_helpers_test.rb +12 -16
  80. data/test/controllers/url_helpers_test.rb +21 -10
  81. data/test/devise_test.rb +16 -25
  82. data/test/encryptors_test.rb +2 -3
  83. data/test/failure_app_test.rb +106 -27
  84. data/test/integration/authenticatable_test.rb +138 -126
  85. data/test/integration/confirmable_test.rb +22 -15
  86. data/test/integration/database_authenticatable_test.rb +38 -0
  87. data/test/integration/http_authenticatable_test.rb +9 -12
  88. data/test/integration/lockable_test.rb +22 -15
  89. data/test/integration/recoverable_test.rb +6 -6
  90. data/test/integration/registerable_test.rb +42 -33
  91. data/test/integration/rememberable_test.rb +84 -22
  92. data/test/integration/timeoutable_test.rb +16 -4
  93. data/test/integration/token_authenticatable_test.rb +45 -12
  94. data/test/integration/trackable_test.rb +1 -1
  95. data/test/mailers/confirmation_instructions_test.rb +11 -17
  96. data/test/mailers/reset_password_instructions_test.rb +7 -7
  97. data/test/mailers/unlock_instructions_test.rb +7 -7
  98. data/test/mapping_test.rb +22 -95
  99. data/test/models/confirmable_test.rb +12 -19
  100. data/test/models/{authenticatable_test.rb → database_authenticatable_test.rb} +24 -56
  101. data/test/models/lockable_test.rb +32 -46
  102. data/test/models/recoverable_test.rb +7 -7
  103. data/test/models/rememberable_test.rb +118 -35
  104. data/test/models/timeoutable_test.rb +1 -1
  105. data/test/models/token_authenticatable_test.rb +5 -19
  106. data/test/models/trackable_test.rb +1 -1
  107. data/test/models/validatable_test.rb +20 -27
  108. data/test/models_test.rb +12 -5
  109. data/test/orm/active_record.rb +1 -23
  110. data/test/orm/mongoid.rb +10 -0
  111. data/test/rails_app/app/active_record/admin.rb +1 -5
  112. data/test/rails_app/app/active_record/shim.rb +2 -0
  113. data/test/rails_app/app/active_record/user.rb +3 -3
  114. data/test/rails_app/app/controllers/application_controller.rb +2 -5
  115. data/test/rails_app/app/controllers/home_controller.rb +3 -0
  116. data/test/rails_app/app/controllers/publisher/registrations_controller.rb +2 -0
  117. data/test/rails_app/app/controllers/publisher/sessions_controller.rb +2 -0
  118. data/test/rails_app/app/controllers/sessions_controller.rb +6 -0
  119. data/test/rails_app/app/controllers/users_controller.rb +7 -5
  120. data/test/rails_app/app/mongoid/admin.rb +6 -0
  121. data/test/rails_app/app/mongoid/shim.rb +16 -0
  122. data/test/rails_app/app/mongoid/user.rb +10 -0
  123. data/test/rails_app/config/application.rb +35 -0
  124. data/test/rails_app/config/boot.rb +10 -107
  125. data/test/rails_app/config/environment.rb +4 -41
  126. data/test/rails_app/config/environments/development.rb +15 -13
  127. data/test/rails_app/config/environments/production.rb +25 -20
  128. data/test/rails_app/config/environments/test.rb +33 -28
  129. data/test/rails_app/config/initializers/backtrace_silencers.rb +7 -0
  130. data/test/rails_app/config/initializers/devise.rb +95 -38
  131. data/test/rails_app/config/initializers/secret_token.rb +2 -0
  132. data/test/rails_app/config/routes.rb +47 -25
  133. data/test/rails_app/db/migrate/20100401102949_create_tables.rb +27 -0
  134. data/test/rails_app/db/schema.rb +86 -0
  135. data/test/routes_test.rb +62 -47
  136. data/test/support/{assertions_helper.rb → assertions.rb} +2 -15
  137. data/test/support/{tests_helper.rb → helpers.rb} +18 -3
  138. data/test/support/{integration_tests_helper.rb → integration.rb} +24 -7
  139. data/test/support/webrat/integrations/rails.rb +32 -0
  140. data/test/test_helper.rb +11 -11
  141. data/test/test_helpers_test.rb +30 -15
  142. metadata +105 -64
  143. data/app/controllers/sessions_controller.rb +0 -42
  144. data/app/models/devise_mailer.rb +0 -68
  145. data/app/views/confirmations/new.html.erb +0 -12
  146. data/app/views/passwords/edit.html.erb +0 -16
  147. data/app/views/passwords/new.html.erb +0 -12
  148. data/app/views/registrations/edit.html.erb +0 -25
  149. data/app/views/registrations/new.html.erb +0 -17
  150. data/app/views/sessions/new.html.erb +0 -17
  151. data/app/views/shared/_devise_links.erb +0 -19
  152. data/app/views/unlocks/new.html.erb +0 -12
  153. data/generators/devise/USAGE +0 -5
  154. data/generators/devise/devise_generator.rb +0 -15
  155. data/generators/devise/lib/route_devise.rb +0 -32
  156. data/generators/devise/templates/model.rb +0 -9
  157. data/generators/devise_install/USAGE +0 -3
  158. data/generators/devise_install/devise_install_generator.rb +0 -15
  159. data/generators/devise_install/templates/devise.rb +0 -105
  160. data/generators/devise_views/USAGE +0 -3
  161. data/generators/devise_views/devise_views_generator.rb +0 -21
  162. data/lib/devise/models/activatable.rb +0 -16
  163. data/lib/devise/models/http_authenticatable.rb +0 -23
  164. data/lib/devise/orm/data_mapper.rb +0 -83
  165. data/lib/devise/orm/mongo_mapper.rb +0 -52
  166. data/lib/devise/strategies/http_authenticatable.rb +0 -59
  167. data/rails/init.rb +0 -2
  168. data/test/integration/rack_middleware_test.rb +0 -47
  169. data/test/orm/mongo_mapper.rb +0 -20
  170. data/test/rails_app/app/mongo_mapper/admin.rb +0 -13
  171. data/test/rails_app/app/mongo_mapper/user.rb +0 -14
  172. data/test/rails_app/config/initializers/new_rails_defaults.rb +0 -24
  173. data/test/rails_app/config/initializers/session_store.rb +0 -15
  174. /data/app/views/{devise_mailer → devise/mailer}/confirmation_instructions.html.erb +0 -0
  175. /data/app/views/{devise_mailer → devise/mailer}/reset_password_instructions.html.erb +0 -0
  176. /data/app/views/{devise_mailer → devise/mailer}/unlock_instructions.html.erb +0 -0
@@ -2,11 +2,8 @@
2
2
  # Likewise, all the methods added will be available for all controllers.
3
3
 
4
4
  class ApplicationController < ActionController::Base
5
- helper :all # include all helpers, all the time
6
- protect_from_forgery # See ActionController::RequestForgeryProtection for details
7
-
8
- # Scrub sensitive parameters from your log
9
- filter_parameter_logging :password
5
+ protect_from_forgery
10
6
 
11
7
  before_filter :current_user
8
+ before_filter :authenticate_user!, :if => :devise_controller?
12
9
  end
@@ -1,4 +1,7 @@
1
1
  class HomeController < ApplicationController
2
2
  def index
3
3
  end
4
+
5
+ def private
6
+ end
4
7
  end
@@ -0,0 +1,2 @@
1
+ class Publisher::RegistrationsController < ApplicationController
2
+ end
@@ -0,0 +1,2 @@
1
+ class Publisher::SessionsController < ApplicationController
2
+ end
@@ -0,0 +1,6 @@
1
+ class SessionsController < Devise::SessionsController
2
+ def new
3
+ flash[:special] = "Welcome to #{controller_path.inspect} controller!"
4
+ super
5
+ end
6
+ end
@@ -1,16 +1,18 @@
1
1
  class UsersController < ApplicationController
2
- before_filter :authenticate_user!
2
+ before_filter :authenticate_user!, :except => :accept
3
+ respond_to :html, :xml
3
4
 
4
5
  def index
5
6
  user_session[:cart] = "Cart"
7
+ respond_with(current_user)
8
+ end
9
+
10
+ def accept
11
+ @current_user = current_user
6
12
  end
7
13
 
8
14
  def expire
9
15
  user_session['last_request_at'] = 31.minutes.ago.utc
10
16
  render :text => 'User will be expired on next request'
11
17
  end
12
-
13
- def show
14
- render :text => current_user.id.to_s
15
- end
16
18
  end
@@ -0,0 +1,6 @@
1
+ class Admin
2
+ include Mongoid::Document
3
+ include Shim
4
+
5
+ devise :database_authenticatable, :timeoutable, :registerable, :recoverable, :lockable, :unlock_strategy => :time
6
+ end
@@ -0,0 +1,16 @@
1
+ module Shim
2
+ extend ::ActiveSupport::Concern
3
+ include ::Mongoid::Timestamps
4
+
5
+ module ClassMethods
6
+ def last(options={})
7
+ options.delete(:order) if options[:order] == "id"
8
+ super(options)
9
+ end
10
+ end
11
+
12
+ # overwrite equality (because some devise tests use this for asserting model equality)
13
+ def ==(other)
14
+ other.is_a?(self.class) && _id == other._id
15
+ end
16
+ end
@@ -0,0 +1,10 @@
1
+ class User
2
+ include Mongoid::Document
3
+ include Shim
4
+
5
+ field :created_at, :type => DateTime
6
+
7
+ devise :database_authenticatable, :confirmable, :lockable, :recoverable,
8
+ :registerable, :rememberable, :timeoutable, :token_authenticatable,
9
+ :trackable, :validatable
10
+ end
@@ -0,0 +1,35 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require "action_controller/railtie"
4
+ require "action_mailer/railtie"
5
+ require "active_resource/railtie"
6
+ require "rails/test_unit/railtie"
7
+
8
+ Bundler.require :default, DEVISE_ORM
9
+
10
+ begin
11
+ require "#{DEVISE_ORM}/railtie"
12
+ rescue LoadError
13
+ end
14
+
15
+ require "devise"
16
+
17
+ module RailsApp
18
+ class Application < Rails::Application
19
+ # Add additional load paths for your own custom dirs
20
+ config.autoload_paths.reject!{ |p| p =~ /\/app\/(\w+)$/ && !%w(controllers helpers views).include?($1) }
21
+ config.autoload_paths += [ "#{config.root}/app/#{DEVISE_ORM}" ]
22
+
23
+ # Configure generators values. Many other options are available, be sure to check the documentation.
24
+ # config.generators do |g|
25
+ # g.orm :active_record
26
+ # g.template_engine :erb
27
+ # g.test_framework :test_unit, :fixture => true
28
+ # end
29
+
30
+ # Configure sensitive parameters which will be filtered from the log file.
31
+ config.filter_parameters << :password
32
+
33
+ config.action_mailer.default_url_options = { :host => "localhost:3000" }
34
+ end
35
+ end
@@ -1,110 +1,13 @@
1
- # Don't change this file!
2
- # Configure your app in config/environment.rb and config/environments/*.rb
3
-
4
- RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
5
-
6
- module Rails
7
- class << self
8
- def boot!
9
- unless booted?
10
- preinitialize
11
- pick_boot.run
12
- end
13
- end
14
-
15
- def booted?
16
- defined? Rails::Initializer
17
- end
18
-
19
- def pick_boot
20
- (vendor_rails? ? VendorBoot : GemBoot).new
21
- end
22
-
23
- def vendor_rails?
24
- File.exist?("#{RAILS_ROOT}/vendor/rails")
25
- end
26
-
27
- def preinitialize
28
- load(preinitializer_path) if File.exist?(preinitializer_path)
29
- end
30
-
31
- def preinitializer_path
32
- "#{RAILS_ROOT}/config/preinitializer.rb"
33
- end
34
- end
35
-
36
- class Boot
37
- def run
38
- load_initializer
39
- Rails::Initializer.run(:set_load_path)
40
- end
41
- end
42
-
43
- class VendorBoot < Boot
44
- def load_initializer
45
- require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
46
- Rails::Initializer.run(:install_gem_spec_stubs)
47
- Rails::GemDependency.add_frozen_gem_path
48
- end
49
- end
50
-
51
- class GemBoot < Boot
52
- def load_initializer
53
- self.class.load_rubygems
54
- load_rails_gem
55
- require 'initializer'
56
- end
57
-
58
- def load_rails_gem
59
- if version = self.class.gem_version
60
- gem 'rails', version
61
- else
62
- gem 'rails'
63
- end
64
- rescue Gem::LoadError => load_error
65
- $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
66
- exit 1
67
- end
68
-
69
- class << self
70
- def rubygems_version
71
- Gem::RubyGemsVersion rescue nil
72
- end
73
-
74
- def gem_version
75
- if defined? RAILS_GEM_VERSION
76
- RAILS_GEM_VERSION
77
- elsif ENV.include?('RAILS_GEM_VERSION')
78
- ENV['RAILS_GEM_VERSION']
79
- else
80
- parse_gem_version(read_environment_rb)
81
- end
82
- end
83
-
84
- def load_rubygems
85
- min_version = '1.3.2'
86
- require 'rubygems'
87
- unless rubygems_version >= min_version
88
- $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
89
- exit 1
90
- end
91
-
92
- rescue LoadError
93
- $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
94
- exit 1
95
- end
96
-
97
- def parse_gem_version(text)
98
- $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
99
- end
1
+ unless defined?(DEVISE_ORM)
2
+ DEVISE_ORM = (ENV["DEVISE_ORM"] || :active_record).to_sym
3
+ end
100
4
 
101
- private
102
- def read_environment_rb
103
- File.read("#{RAILS_ROOT}/config/environment.rb")
104
- end
105
- end
106
- end
5
+ begin
6
+ require File.expand_path("../../../../.bundle/environment", __FILE__)
7
+ rescue LoadError
8
+ require 'rubygems'
9
+ require 'bundler'
10
+ Bundler.setup :default, DEVISE_ORM
107
11
  end
108
12
 
109
- # All that for this:
110
- Rails.boot!
13
+ $:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -1,42 +1,5 @@
1
- # Be sure to restart your server when you modify this file
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
2
3
 
3
- # Specifies gem version of Rails to use when vendor/rails is not present
4
- RAILS_GEM_VERSION = '2.3.11' unless defined? RAILS_GEM_VERSION
5
- DEVISE_ORM = :active_record unless defined? DEVISE_ORM
6
-
7
- # Bootstrap the Rails environment, frameworks, and default configuration
8
- require File.join(File.dirname(__FILE__), 'boot')
9
-
10
- Rails::Initializer.run do |config|
11
- # Settings in config/environments/* take precedence over those specified here.
12
- # Application configuration should go into files in config/initializers
13
- # -- all .rb files in that directory are automatically loaded.
14
-
15
- # Add additional load paths for your own custom dirs
16
- config.autoload_paths += [ "#{RAILS_ROOT}/app/#{DEVISE_ORM}/" ]
17
-
18
- # Specify gems that this application depends on and have them installed with rake gems:install
19
- # config.gem "bj"
20
- # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
21
- # config.gem "sqlite3-ruby", :lib => "sqlite3"
22
- # config.gem "aws-s3", :lib => "aws/s3"
23
-
24
- # Only load the plugins named here, in the order given (default is alphabetical).
25
- # :all can be used as a placeholder for all plugins not explicitly named
26
- # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
27
-
28
- # Skip frameworks you're not going to use. To use Rails without a database,
29
- # you must remove the Active Record framework.
30
- config.frameworks -= [ :active_record ] unless DEVISE_ORM == :active_record
31
-
32
- # Activate observers that should always be running
33
- # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
34
-
35
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
36
- # Run "rake -D time" for a list of tasks for finding time zone names.
37
- config.time_zone = 'UTC'
38
-
39
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
40
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
41
- # config.i18n.default_locale = :en
42
- end
4
+ # Initialize the rails application
5
+ RailsApp::Application.initialize!
@@ -1,17 +1,19 @@
1
- # Settings specified here will take precedence over those in config/environment.rb
1
+ RailsApp::Application.configure do
2
+ # Settings specified here will take precedence over those in config/environment.rb
2
3
 
3
- # In the development environment your application's code is reloaded on
4
- # every request. This slows down response time but is perfect for development
5
- # since you don't have to restart the webserver when you make code changes.
6
- config.cache_classes = false
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the webserver when you make code changes.
7
+ config.cache_classes = false
7
8
 
8
- # Log error messages when you accidentally call methods on nil.
9
- config.whiny_nils = true
9
+ # Log error messages when you accidentally call methods on nil.
10
+ config.whiny_nils = true
10
11
 
11
- # Show full error reports and disable caching
12
- config.action_controller.consider_all_requests_local = true
13
- config.action_view.debug_rjs = true
14
- config.action_controller.perform_caching = false
12
+ # Show full error reports and disable caching
13
+ config.consider_all_requests_local = true
14
+ config.action_view.debug_rjs = true
15
+ config.action_controller.perform_caching = false
15
16
 
16
- # Don't care if the mailer can't send
17
- config.action_mailer.raise_delivery_errors = false
17
+ # Don't care if the mailer can't send
18
+ config.action_mailer.raise_delivery_errors = false
19
+ end
@@ -1,28 +1,33 @@
1
- # Settings specified here will take precedence over those in config/environment.rb
1
+ RailsApp::Application.configure do
2
+ # Settings specified here will take precedence over those in config/environment.rb
2
3
 
3
- # The production environment is meant for finished, "live" apps.
4
- # Code is not reloaded between requests
5
- config.cache_classes = true
4
+ # The production environment is meant for finished, "live" apps.
5
+ # Code is not reloaded between requests
6
+ config.cache_classes = true
6
7
 
7
- # Full error reports are disabled and caching is turned on
8
- config.action_controller.consider_all_requests_local = false
9
- config.action_controller.perform_caching = true
10
- config.action_view.cache_template_loading = true
8
+ # Full error reports are disabled and caching is turned on
9
+ config.consider_all_requests_local = false
10
+ config.action_controller.perform_caching = true
11
11
 
12
- # See everything in the log (default is :info)
13
- # config.log_level = :debug
12
+ # See everything in the log (default is :info)
13
+ # config.log_level = :debug
14
14
 
15
- # Use a different logger for distributed setups
16
- # config.logger = SyslogLogger.new
15
+ # Use a different logger for distributed setups
16
+ # config.logger = SyslogLogger.new
17
17
 
18
- # Use a different cache store in production
19
- # config.cache_store = :mem_cache_store
18
+ # Use a different cache store in production
19
+ # config.cache_store = :mem_cache_store
20
20
 
21
- # Enable serving of images, stylesheets, and javascripts from an asset server
22
- # config.action_controller.asset_host = "http://assets.example.com"
21
+ # Disable Rails's static asset server
22
+ # In production, Apache or nginx will already do this
23
+ config.serve_static_assets = false
23
24
 
24
- # Disable delivery errors, bad email addresses will be ignored
25
- # config.action_mailer.raise_delivery_errors = false
25
+ # Enable serving of images, stylesheets, and javascripts from an asset server
26
+ # config.action_controller.asset_host = "http://assets.example.com"
26
27
 
27
- # Enable threaded mode
28
- # config.threadsafe!
28
+ # Disable delivery errors, bad email addresses will be ignored
29
+ # config.action_mailer.raise_delivery_errors = false
30
+
31
+ # Enable threaded mode
32
+ # config.threadsafe!
33
+ end
@@ -1,28 +1,33 @@
1
- # Settings specified here will take precedence over those in config/environment.rb
2
-
3
- # The test environment is used exclusively to run your application's
4
- # test suite. You never need to work with it otherwise. Remember that
5
- # your test database is "scratch space" for the test suite and is wiped
6
- # and recreated between test runs. Don't rely on the data there!
7
- config.cache_classes = true
8
-
9
- # Log error messages when you accidentally call methods on nil.
10
- config.whiny_nils = true
11
-
12
- # Show full error reports and disable caching
13
- config.action_controller.consider_all_requests_local = true
14
- config.action_controller.perform_caching = false
15
- config.action_view.cache_template_loading = true
16
-
17
- # Disable request forgery protection in test environment
18
- config.action_controller.allow_forgery_protection = false
19
-
20
- # Tell Action Mailer not to deliver emails to the real world.
21
- # The :test delivery method accumulates sent emails in the
22
- # ActionMailer::Base.deliveries array.
23
- config.action_mailer.delivery_method = :test
24
-
25
- # Use SQL instead of Active Record's schema dumper when creating the test database.
26
- # This is necessary if your schema can't be completely dumped by the schema dumper,
27
- # like if you have constraints or database-specific column types
28
- # config.active_record.schema_format = :sql
1
+ RailsApp::Application.configure do
2
+ # Settings specified here will take precedence over those in config/environment.rb
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ # Log error messages when you accidentally call methods on nil.
11
+ config.whiny_nils = true
12
+
13
+ # Show full error reports and disable caching
14
+ config.consider_all_requests_local = true
15
+ config.action_controller.perform_caching = false
16
+
17
+ # Disable request forgery protection in test environment
18
+ config.action_controller.allow_forgery_protection = false
19
+
20
+ # Tell Action Mailer not to deliver emails to the real world.
21
+ # The :test delivery method accumulates sent emails in the
22
+ # ActionMailer::Base.deliveries array.
23
+ config.action_mailer.delivery_method = :test
24
+
25
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
26
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
27
+ # like if you have constraints or database-specific column types
28
+ # config.active_record.schema_format = :sql
29
+
30
+ config.action_dispatch.show_exceptions = false
31
+
32
+ config.active_support.deprecation = :stderr
33
+ end
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
+ Rails.backtrace_cleaner.remove_silencers!
@@ -1,20 +1,20 @@
1
1
  # Use this hook to configure devise mailer, warden hooks and so forth. The first
2
2
  # four configuration values can also be set straight in your models.
3
3
  Devise.setup do |config|
4
- # Invoke `rake secret` and use the printed value to setup a pepper to generate
5
- # the encrypted password. By default no pepper is used.
6
- # config.pepper = "rake secret output"
4
+ # ==> Mailer Configuration
5
+ # Configure the e-mail address which will be shown in DeviseMailer.
6
+ config.mailer_sender = "please-change-me@config-initializers-devise.com"
7
7
 
8
- # Configure how many times you want the password is reencrypted. Default is 10.
9
- # config.stretches = 10
8
+ # Configure the class responsible to send e-mails.
9
+ # config.mailer = "Devise::Mailer"
10
10
 
11
- # Define which will be the encryption algorithm. Supported algorithms are :sha1
12
- # (default) and :sha512. Devise also supports encryptors from others authentication
13
- # frameworks as :clearance_sha1, :authlogic_sha512 (then you should set stretches
14
- # above to 20 for default behavior) and :restful_authentication_sha1 (then you
15
- # should set stretches to 10, and copy REST_AUTH_SITE_KEY to pepper)
16
- # config.encryptor = :sha1
11
+ # ==> ORM configuration
12
+ # Load and configure the ORM. Supports :active_record (default) and
13
+ # :mongoid (bson_ext recommended) by default. Other ORMs may be
14
+ # available as additional gems.
15
+ require "devise/orm/#{DEVISE_ORM}"
17
16
 
17
+ # ==> Configuration for any authentication mechanism
18
18
  # Configure which keys are used when authenticating an user. By default is
19
19
  # just :email. You can configure it to use [:username, :subdomain], so for
20
20
  # authenticating an user, both parameters are required. Remember that those
@@ -22,44 +22,108 @@ Devise.setup do |config|
22
22
  # session. If you need permissions, you should implement that in a before filter.
23
23
  # config.authentication_keys = [ :email ]
24
24
 
25
- # The time you want give to your user to confirm his account. During this time
25
+ # Tell if authentication through request.params is enabled. True by default.
26
+ # config.params_authenticatable = true
27
+
28
+ # Tell if authentication through HTTP Basic Auth is enabled. True by default.
29
+ # config.http_authenticatable = true
30
+
31
+ # The realm used in Http Basic Authentication
32
+ # config.http_authentication_realm = "Application"
33
+
34
+ # ==> Configuration for :database_authenticatable
35
+ # For bcrypt, this is the cost for hashing the password and defaults to 10. If
36
+ # using other encryptors, it sets how many times you want the password re-encrypted.
37
+ config.stretches = 10
38
+
39
+ # Define which will be the encryption algorithm. Devise also supports encryptors
40
+ # from others authentication tools as :clearance_sha1, :authlogic_sha512 (then
41
+ # you should set stretches above to 20 for default behavior) and :restful_authentication_sha1
42
+ # (then you should set stretches to 10, and copy REST_AUTH_SITE_KEY to pepper)
43
+ config.encryptor = :bcrypt
44
+
45
+ # Setup a pepper to generate the encrypted password.
46
+ config.pepper = "d142367154e5beacca404b1a6a4f8bc52c6fdcfa3ccc3cf8eb49f3458a688ee6ac3b9fae488432a3bfca863b8a90008368a9f3a3dfbe5a962e64b6ab8f3a3a1a"
47
+
48
+ # ==> Configuration for :confirmable
49
+ # The time you want to give your user to confirm his account. During this time
26
50
  # he will be able to access your application without confirming. Default is nil.
51
+ # When confirm_within is zero, the user won't be able to sign in without confirming.
52
+ # You can use this to let your user access some features of your application
53
+ # without confirming the account, but blocking it after a certain period
54
+ # (ie 2 days).
27
55
  # config.confirm_within = 2.days
28
56
 
57
+ # ==> Configuration for :rememberable
29
58
  # The time the user will be remembered without asking for credentials again.
30
59
  # config.remember_for = 2.weeks
31
60
 
61
+ # If true, a valid remember token can be re-used between multiple browsers.
62
+ # config.remember_across_browsers = true
63
+
64
+ # If true, extends the user's remember period when remembered via cookie.
65
+ # config.extend_remember_period = false
66
+
67
+ # ==> Configuration for :validatable
68
+ # Range for password length
69
+ # config.password_length = 6..20
70
+
71
+ # Regex to use to validate the email address
72
+ # config.email_regexp = /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i
73
+
74
+ # ==> Configuration for :timeoutable
32
75
  # The time you want to timeout the user session without activity. After this
33
76
  # time the user will be asked for credentials again.
34
77
  # config.timeout_in = 10.minutes
35
78
 
36
- # Configure the e-mail address which will be shown in DeviseMailer.
37
- config.mailer_sender = "please-change-me-omg@yourapp.com"
38
-
39
- # Configure the content type of DeviseMailer mails (defaults to text/html")
40
- # config.mailer_content_type = "text/plain"
79
+ # ==> Configuration for :lockable
80
+ # Defines which strategy will be used to lock an account.
81
+ # :failed_attempts = Locks an account after a number of failed attempts to sign in.
82
+ # :none = No lock strategy. You should handle locking by yourself.
83
+ # config.lock_strategy = :failed_attempts
41
84
 
42
- # Load and configure the ORM. Supports :active_record, :data_mapper and :mongo_mapper.
43
- require "devise/orm/#{DEVISE_ORM}"
44
- config.orm = DEVISE_ORM
85
+ # Defines which strategy will be used to unlock an account.
86
+ # :email = Sends an unlock link to the user email
87
+ # :time = Re-enables login after a certain amount of time (see :unlock_in below)
88
+ # :both = Enables both strategies
89
+ # :none = No unlock strategy. You should handle unlocking by yourself.
90
+ # config.unlock_strategy = :both
91
+
92
+ # Number of authentication tries before locking an account if lock_strategy
93
+ # is failed attempts.
94
+ # config.maximum_attempts = 20
95
+
96
+ # Time interval to unlock the account if :time is enabled as unlock_strategy.
97
+ # config.unlock_in = 1.hour
45
98
 
99
+ # ==> Configuration for :token_authenticatable
100
+ # Defines name of the authentication token params key
101
+ # config.token_authentication_key = :auth_token
102
+
103
+ # ==> Scopes configuration
46
104
  # Turn scoped views on. Before rendering "sessions/new", it will first check for
47
- # "sessions/users/new". It's turned off by default because it's slower if you
105
+ # "users/sessions/new". It's turned off by default because it's slower if you
48
106
  # are using only default views.
49
107
  # config.scoped_views = true
50
108
 
51
- # Number of authentication tries before locking an account.
52
- # config.maximum_attempts = 20
109
+ # Configure the default scope given to Warden. By default it's the first
110
+ # devise role declared in your routes.
111
+ # config.default_scope = :user
53
112
 
54
- # Defines which strategy will be used to unlock an account.
55
- # :email = Sends an unlock link to the user email
56
- # :time = Reanables login after a certain ammount of time (see :unlock_in below)
57
- # :both = enables both strategies
58
- # config.unlock_strategy = :both
113
+ # Configure sign_out behavior.
114
+ # By default sign_out is scoped (i.e. /users/sign_out affects only :user scope).
115
+ # In case of sign_out_all_scopes set to true any logout action will sign out all active scopes.
116
+ # config.sign_out_all_scopes = false
59
117
 
60
- # Time interval to unlock the account if :time is enabled as unlock_strategy.
61
- # config.unlock_in = 1.hour
118
+ # ==> Navigation configuration
119
+ # Lists the formats that should be treated as navigational. Formats like
120
+ # :html, should redirect to the sign in page when the user does not have
121
+ # access, but formats like :xml or :json, should return 401.
122
+ # If you have any extra navigational formats, like :iphone or :mobile, you
123
+ # should add them to the navigational formats lists. Default is [:html]
124
+ # config.navigational_formats = [:html, :iphone]
62
125
 
126
+ # ==> Warden configuration
63
127
  # If you want to use other strategies, that are not (yet) supported by Devise,
64
128
  # you can configure them inside the config.warden block. The example below
65
129
  # allows you to setup OAuth, using http://github.com/roman/warden_oauth
@@ -70,13 +134,6 @@ Devise.setup do |config|
70
134
  # twitter.consumer_key = <YOUR CONSUMER KEY>
71
135
  # twitter.options :site => 'http://twitter.com'
72
136
  # end
73
- # manager.default_strategies.unshift :twitter_oauth
74
- # end
75
-
76
- # Configure default_url_options if you are using dynamic segments in :path_prefix
77
- # for devise_for.
78
- #
79
- # config.default_url_options do
80
- # { :locale => I18n.locale }
137
+ # manager.default_strategies(:scope => :user).unshift :twitter_oauth
81
138
  # end
82
139
  end
@@ -0,0 +1,2 @@
1
+ Rails.application.config.secret_token = 'ea942c41850d502f2c8283e26bdc57829f471bb18224ddff0a192c4f32cdf6cb5aa0d82b3a7a7adbeb640c4b06f3aa1cd5f098162d8240f669b39d6b49680571'
2
+ Rails.application.config.session_store :cookie_store, :key => "_my_app"