gonow-devise 1.2.rc

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. data/CHANGELOG.rdoc +506 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +335 -0
  4. data/app/controllers/devise/confirmations_controller.rb +33 -0
  5. data/app/controllers/devise/oauth_callbacks_controller.rb +4 -0
  6. data/app/controllers/devise/passwords_controller.rb +41 -0
  7. data/app/controllers/devise/registrations_controller.rb +109 -0
  8. data/app/controllers/devise/sessions_controller.rb +24 -0
  9. data/app/controllers/devise/unlocks_controller.rb +34 -0
  10. data/app/helpers/devise_helper.rb +19 -0
  11. data/app/mailers/devise/mailer.rb +88 -0
  12. data/app/views/devise/confirmations/new.html.erb +12 -0
  13. data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
  14. data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  15. data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  16. data/app/views/devise/passwords/edit.html.erb +16 -0
  17. data/app/views/devise/passwords/new.html.erb +12 -0
  18. data/app/views/devise/registrations/edit.html.erb +25 -0
  19. data/app/views/devise/registrations/new.html.erb +18 -0
  20. data/app/views/devise/sessions/new.html.erb +17 -0
  21. data/app/views/devise/shared/_links.erb +25 -0
  22. data/app/views/devise/unlocks/new.html.erb +12 -0
  23. data/config/locales/en.yml +46 -0
  24. data/lib/devise.rb +372 -0
  25. data/lib/devise/controllers/helpers.rb +228 -0
  26. data/lib/devise/controllers/internal_helpers.rb +113 -0
  27. data/lib/devise/controllers/scoped_views.rb +33 -0
  28. data/lib/devise/controllers/url_helpers.rb +39 -0
  29. data/lib/devise/encryptors/authlogic_sha512.rb +19 -0
  30. data/lib/devise/encryptors/base.rb +20 -0
  31. data/lib/devise/encryptors/clearance_sha1.rb +17 -0
  32. data/lib/devise/encryptors/restful_authentication_sha1.rb +22 -0
  33. data/lib/devise/encryptors/sha1.rb +25 -0
  34. data/lib/devise/encryptors/sha512.rb +25 -0
  35. data/lib/devise/failure_app.rb +126 -0
  36. data/lib/devise/hooks/activatable.rb +11 -0
  37. data/lib/devise/hooks/forgetable.rb +12 -0
  38. data/lib/devise/hooks/rememberable.rb +45 -0
  39. data/lib/devise/hooks/timeoutable.rb +22 -0
  40. data/lib/devise/hooks/trackable.rb +9 -0
  41. data/lib/devise/mapping.rb +105 -0
  42. data/lib/devise/models.rb +66 -0
  43. data/lib/devise/models/authenticatable.rb +143 -0
  44. data/lib/devise/models/confirmable.rb +160 -0
  45. data/lib/devise/models/database_authenticatable.rb +94 -0
  46. data/lib/devise/models/encryptable.rb +65 -0
  47. data/lib/devise/models/lockable.rb +168 -0
  48. data/lib/devise/models/oauthable.rb +49 -0
  49. data/lib/devise/models/recoverable.rb +83 -0
  50. data/lib/devise/models/registerable.rb +21 -0
  51. data/lib/devise/models/rememberable.rb +122 -0
  52. data/lib/devise/models/timeoutable.rb +43 -0
  53. data/lib/devise/models/token_authenticatable.rb +72 -0
  54. data/lib/devise/models/trackable.rb +30 -0
  55. data/lib/devise/models/validatable.rb +64 -0
  56. data/lib/devise/modules.rb +30 -0
  57. data/lib/devise/oauth.rb +41 -0
  58. data/lib/devise/oauth/config.rb +33 -0
  59. data/lib/devise/oauth/helpers.rb +18 -0
  60. data/lib/devise/oauth/internal_helpers.rb +182 -0
  61. data/lib/devise/oauth/test_helpers.rb +29 -0
  62. data/lib/devise/oauth/url_helpers.rb +35 -0
  63. data/lib/devise/orm/active_record.rb +38 -0
  64. data/lib/devise/orm/mongoid.rb +31 -0
  65. data/lib/devise/path_checker.rb +18 -0
  66. data/lib/devise/rails.rb +68 -0
  67. data/lib/devise/rails/routes.rb +260 -0
  68. data/lib/devise/rails/warden_compat.rb +41 -0
  69. data/lib/devise/schema.rb +96 -0
  70. data/lib/devise/strategies/authenticatable.rb +150 -0
  71. data/lib/devise/strategies/base.rb +15 -0
  72. data/lib/devise/strategies/database_authenticatable.rb +21 -0
  73. data/lib/devise/strategies/rememberable.rb +51 -0
  74. data/lib/devise/strategies/token_authenticatable.rb +53 -0
  75. data/lib/devise/test_helpers.rb +100 -0
  76. data/lib/devise/version.rb +3 -0
  77. data/lib/generators/active_record/devise_generator.rb +28 -0
  78. data/lib/generators/active_record/templates/migration.rb +30 -0
  79. data/lib/generators/devise/devise_generator.rb +17 -0
  80. data/lib/generators/devise/install_generator.rb +24 -0
  81. data/lib/generators/devise/orm_helpers.rb +24 -0
  82. data/lib/generators/devise/views_generator.rb +63 -0
  83. data/lib/generators/mongoid/devise_generator.rb +17 -0
  84. data/lib/generators/templates/README +25 -0
  85. data/lib/generators/templates/devise.rb +168 -0
  86. data/test/controllers/helpers_test.rb +205 -0
  87. data/test/controllers/internal_helpers_test.rb +56 -0
  88. data/test/controllers/url_helpers_test.rb +59 -0
  89. data/test/devise_test.rb +65 -0
  90. data/test/encryptors_test.rb +30 -0
  91. data/test/failure_app_test.rb +148 -0
  92. data/test/generators/generators_test_helper.rb +4 -0
  93. data/test/generators/install_generator_test.rb +14 -0
  94. data/test/generators/views_generator_test.rb +37 -0
  95. data/test/integration/authenticatable_test.rb +424 -0
  96. data/test/integration/confirmable_test.rb +104 -0
  97. data/test/integration/database_authenticatable_test.rb +38 -0
  98. data/test/integration/http_authenticatable_test.rb +64 -0
  99. data/test/integration/lockable_test.rb +109 -0
  100. data/test/integration/oauthable_test.rb +244 -0
  101. data/test/integration/recoverable_test.rb +134 -0
  102. data/test/integration/registerable_test.rb +180 -0
  103. data/test/integration/rememberable_test.rb +179 -0
  104. data/test/integration/timeoutable_test.rb +89 -0
  105. data/test/integration/token_authenticatable_test.rb +99 -0
  106. data/test/integration/trackable_test.rb +64 -0
  107. data/test/mailers/confirmation_instructions_test.rb +84 -0
  108. data/test/mailers/reset_password_instructions_test.rb +72 -0
  109. data/test/mailers/unlock_instructions_test.rb +66 -0
  110. data/test/mapping_test.rb +95 -0
  111. data/test/models/confirmable_test.rb +221 -0
  112. data/test/models/database_authenticatable_test.rb +82 -0
  113. data/test/models/encryptable_test.rb +65 -0
  114. data/test/models/lockable_test.rb +204 -0
  115. data/test/models/oauthable_test.rb +21 -0
  116. data/test/models/recoverable_test.rb +155 -0
  117. data/test/models/rememberable_test.rb +271 -0
  118. data/test/models/timeoutable_test.rb +28 -0
  119. data/test/models/token_authenticatable_test.rb +37 -0
  120. data/test/models/trackable_test.rb +5 -0
  121. data/test/models/validatable_test.rb +99 -0
  122. data/test/models_test.rb +77 -0
  123. data/test/oauth/config_test.rb +44 -0
  124. data/test/oauth/url_helpers_test.rb +47 -0
  125. data/test/orm/active_record.rb +9 -0
  126. data/test/orm/mongoid.rb +10 -0
  127. data/test/rails_app/app/active_record/admin.rb +6 -0
  128. data/test/rails_app/app/active_record/shim.rb +2 -0
  129. data/test/rails_app/app/active_record/user.rb +8 -0
  130. data/test/rails_app/app/controllers/admins/sessions_controller.rb +6 -0
  131. data/test/rails_app/app/controllers/admins_controller.rb +6 -0
  132. data/test/rails_app/app/controllers/application_controller.rb +9 -0
  133. data/test/rails_app/app/controllers/home_controller.rb +12 -0
  134. data/test/rails_app/app/controllers/publisher/registrations_controller.rb +2 -0
  135. data/test/rails_app/app/controllers/publisher/sessions_controller.rb +2 -0
  136. data/test/rails_app/app/controllers/users_controller.rb +18 -0
  137. data/test/rails_app/app/helpers/application_helper.rb +3 -0
  138. data/test/rails_app/app/mongoid/admin.rb +9 -0
  139. data/test/rails_app/app/mongoid/shim.rb +24 -0
  140. data/test/rails_app/app/mongoid/user.rb +10 -0
  141. data/test/rails_app/config/application.rb +35 -0
  142. data/test/rails_app/config/boot.rb +13 -0
  143. data/test/rails_app/config/environment.rb +5 -0
  144. data/test/rails_app/config/environments/development.rb +19 -0
  145. data/test/rails_app/config/environments/production.rb +33 -0
  146. data/test/rails_app/config/environments/test.rb +33 -0
  147. data/test/rails_app/config/initializers/backtrace_silencers.rb +7 -0
  148. data/test/rails_app/config/initializers/devise.rb +172 -0
  149. data/test/rails_app/config/initializers/inflections.rb +2 -0
  150. data/test/rails_app/config/initializers/secret_token.rb +2 -0
  151. data/test/rails_app/config/routes.rb +54 -0
  152. data/test/rails_app/db/migrate/20100401102949_create_tables.rb +31 -0
  153. data/test/rails_app/db/schema.rb +52 -0
  154. data/test/rails_app/lib/shared_admin.rb +9 -0
  155. data/test/rails_app/lib/shared_user.rb +48 -0
  156. data/test/routes_test.rb +189 -0
  157. data/test/support/assertions.rb +24 -0
  158. data/test/support/helpers.rb +60 -0
  159. data/test/support/integration.rb +88 -0
  160. data/test/support/webrat/integrations/rails.rb +24 -0
  161. data/test/test_helper.rb +23 -0
  162. data/test/test_helpers_test.rb +101 -0
  163. metadata +357 -0
@@ -0,0 +1,3 @@
1
+ # Methods added to this helper will be available to all templates in the application.
2
+ module ApplicationHelper
3
+ end
@@ -0,0 +1,9 @@
1
+ require 'shared_admin'
2
+
3
+ class Admin
4
+ include Mongoid::Document
5
+ include Shim
6
+ include SharedAdmin
7
+
8
+ field :remember_token, :type => String
9
+ end
@@ -0,0 +1,24 @@
1
+ module Shim
2
+ extend ::ActiveSupport::Concern
3
+
4
+ included do
5
+ include ::Mongoid::Timestamps
6
+ field :created_at, :type => DateTime
7
+ end
8
+
9
+ module ClassMethods
10
+ def last(options={})
11
+ options.delete(:order) if options[:order] == "id"
12
+ super(options)
13
+ end
14
+
15
+ def find_by_email(email)
16
+ first(:conditions => { :email => email })
17
+ end
18
+ end
19
+
20
+ # overwrite equality (because some devise tests use this for asserting model equality)
21
+ def ==(other)
22
+ other.is_a?(self.class) && _id == other._id
23
+ end
24
+ end
@@ -0,0 +1,10 @@
1
+ require 'shared_user'
2
+
3
+ class User
4
+ include Mongoid::Document
5
+ include Shim
6
+ include SharedUser
7
+
8
+ field :username, :type => String
9
+ field :facebook_token, :type => String
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
@@ -0,0 +1,13 @@
1
+ unless defined?(DEVISE_ORM)
2
+ DEVISE_ORM = (ENV["DEVISE_ORM"] || :active_record).to_sym
3
+ end
4
+
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
11
+ end
12
+
13
+ $:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ RailsApp::Application.initialize!
@@ -0,0 +1,19 @@
1
+ RailsApp::Application.configure do
2
+ # Settings specified here will take precedence over those in config/environment.rb
3
+
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
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.consider_all_requests_local = true
14
+ config.action_view.debug_rjs = true
15
+ config.action_controller.perform_caching = false
16
+
17
+ # Don't care if the mailer can't send
18
+ config.action_mailer.raise_delivery_errors = false
19
+ end
@@ -0,0 +1,33 @@
1
+ RailsApp::Application.configure do
2
+ # Settings specified here will take precedence over those in config/environment.rb
3
+
4
+ # The production environment is meant for finished, "live" apps.
5
+ # Code is not reloaded between requests
6
+ config.cache_classes = true
7
+
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
+
12
+ # See everything in the log (default is :info)
13
+ # config.log_level = :debug
14
+
15
+ # Use a different logger for distributed setups
16
+ # config.logger = SyslogLogger.new
17
+
18
+ # Use a different cache store in production
19
+ # config.cache_store = :mem_cache_store
20
+
21
+ # Disable Rails's static asset server
22
+ # In production, Apache or nginx will already do this
23
+ config.serve_static_assets = false
24
+
25
+ # Enable serving of images, stylesheets, and javascripts from an asset server
26
+ # config.action_controller.asset_host = "http://assets.example.com"
27
+
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
@@ -0,0 +1,33 @@
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!
@@ -0,0 +1,172 @@
1
+ # Use this hook to configure devise mailer, warden hooks and so forth. The first
2
+ # four configuration values can also be set straight in your models.
3
+ Devise.setup do |config|
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
+
8
+ # Configure the class responsible to send e-mails.
9
+ # config.mailer = "Devise::Mailer"
10
+
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}"
16
+
17
+ # ==> Configuration for any authentication mechanism
18
+ # Configure which keys are used when authenticating an user. By default is
19
+ # just :email. You can configure it to use [:username, :subdomain], so for
20
+ # authenticating an user, both parameters are required. Remember that those
21
+ # parameters are used only when authenticating and not when retrieving from
22
+ # session. If you need permissions, you should implement that in a before filter.
23
+ # You can also supply hash where the value is a boolean expliciting if authentication
24
+ # should be aborted or not if the value is not present. By default is empty.
25
+ # config.authentication_keys = [ :email ]
26
+
27
+ # Configure parameters from the request object used for authentication. Each entry
28
+ # given should be a request method and it will automatically be passed to
29
+ # find_for_authentication method and considered in your model lookup. For instance,
30
+ # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
31
+ # The same considerations mentioned for authentication_keys also apply to request_keys.
32
+ # config.request_keys = []
33
+
34
+ # Tell if authentication through request.params is enabled. True by default.
35
+ # config.params_authenticatable = true
36
+
37
+ # Tell if authentication through HTTP Basic Auth is enabled. False by default.
38
+ config.http_authenticatable = true
39
+
40
+ # If http headers should be returned for AJAX requests. True by default.
41
+ # config.http_authenticatable_on_xhr = true
42
+
43
+ # The realm used in Http Basic Authentication. "Application" by default.
44
+ # config.http_authentication_realm = "Application"
45
+
46
+ # ==> Configuration for :database_authenticatable
47
+ # For bcrypt, this is the cost for hashing the password and defaults to 10. If
48
+ # using other encryptors, it sets how many times you want the password re-encrypted.
49
+ config.stretches = 10
50
+
51
+ # ==> Configuration for :confirmable
52
+ # The time you want to give your user to confirm his account. During this time
53
+ # he will be able to access your application without confirming. Default is nil.
54
+ # When confirm_within is zero, the user won't be able to sign in without confirming.
55
+ # You can use this to let your user access some features of your application
56
+ # without confirming the account, but blocking it after a certain period
57
+ # (ie 2 days).
58
+ # config.confirm_within = 2.days
59
+
60
+ # ==> Configuration for :rememberable
61
+ # The time the user will be remembered without asking for credentials again.
62
+ # config.remember_for = 2.weeks
63
+
64
+ # If true, a valid remember token can be re-used between multiple browsers.
65
+ # config.remember_across_browsers = true
66
+
67
+ # If true, extends the user's remember period when remembered via cookie.
68
+ # config.extend_remember_period = false
69
+
70
+ # If true, uses the password salt as remember token. This should be turned
71
+ # to false if you are not using database authenticatable.
72
+ config.use_salt_as_remember_token = true
73
+
74
+ # ==> Configuration for :validatable
75
+ # Range for password length. Default is 6..20.
76
+ # config.password_length = 6..20
77
+
78
+ # Regex to use to validate the email address
79
+ # config.email_regexp = /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i
80
+
81
+ # ==> Configuration for :timeoutable
82
+ # The time you want to timeout the user session without activity. After this
83
+ # time the user will be asked for credentials again. Default is 30 minutes.
84
+ # config.timeout_in = 30.minutes
85
+
86
+ # ==> Configuration for :lockable
87
+ # Defines which strategy will be used to lock an account.
88
+ # :failed_attempts = Locks an account after a number of failed attempts to sign in.
89
+ # :none = No lock strategy. You should handle locking by yourself.
90
+ # config.lock_strategy = :failed_attempts
91
+
92
+ # Defines which strategy will be used to unlock an account.
93
+ # :email = Sends an unlock link to the user email
94
+ # :time = Re-enables login after a certain amount of time (see :unlock_in below)
95
+ # :both = Enables both strategies
96
+ # :none = No unlock strategy. You should handle unlocking by yourself.
97
+ # config.unlock_strategy = :both
98
+
99
+ # Number of authentication tries before locking an account if lock_strategy
100
+ # is failed attempts.
101
+ # config.maximum_attempts = 20
102
+
103
+ # Time interval to unlock the account if :time is enabled as unlock_strategy.
104
+ # config.unlock_in = 1.hour
105
+
106
+ # ==> Configuration for :encryptable
107
+ # Allow you to use another encryption algorithm besides bcrypt (default). You can use
108
+ # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
109
+ # :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
110
+ # and :restful_authentication_sha1 (then you should set stretches to 10, and copy
111
+ # REST_AUTH_SITE_KEY to pepper)
112
+ config.encryptor = :sha512
113
+
114
+ # Setup a pepper to generate the encrypted password.
115
+ config.pepper = "d142367154e5beacca404b1a6a4f8bc52c6fdcfa3ccc3cf8eb49f3458a688ee6ac3b9fae488432a3bfca863b8a90008368a9f3a3dfbe5a962e64b6ab8f3a3a1a"
116
+
117
+ # ==> Configuration for :token_authenticatable
118
+ # Defines name of the authentication token params key
119
+ # config.token_authentication_key = :auth_token
120
+
121
+ # If true, authentication through token does not store user in session and needs
122
+ # to be supplied on each request. Useful if you are using the token as API token.
123
+ # config.stateless_token = false
124
+
125
+ # ==> Scopes configuration
126
+ # Turn scoped views on. Before rendering "sessions/new", it will first check for
127
+ # "users/sessions/new". It's turned off by default because it's slower if you
128
+ # are using only default views.
129
+ # config.scoped_views = false
130
+
131
+ # Configure the default scope given to Warden. By default it's the first
132
+ # devise role declared in your routes (usually :user).
133
+ # config.default_scope = :user
134
+
135
+ # Configure sign_out behavior.
136
+ # Sign_out action can be scoped (i.e. /users/sign_out affects only :user scope).
137
+ # The default is true, which means any logout action will sign out all active scopes.
138
+ # config.sign_out_all_scopes = true
139
+
140
+ # ==> Navigation configuration
141
+ # Lists the formats that should be treated as navigational. Formats like
142
+ # :html, should redirect to the sign in page when the user does not have
143
+ # access, but formats like :xml or :json, should return 401.
144
+ # If you have any extra navigational formats, like :iphone or :mobile, you
145
+ # should add them to the navigational formats lists. Default is [:html]
146
+ # config.navigational_formats = [:html, :iphone]
147
+
148
+ # The default HTTP method used to sign out a resource. Default is :get.
149
+ # config.sign_out_via = :get
150
+
151
+ # ==> OAuth2
152
+ # Add a new OAuth2 provider. Check the README for more information on setting
153
+ # up on your models and hooks. By default this is not set.
154
+ config.oauth :github, 'APP_ID', 'APP_SECRET',
155
+ :site => 'https://github.com/',
156
+ :authorize_path => '/login/oauth/authorize',
157
+ :access_token_path => '/login/oauth/access_token',
158
+ :scope => 'user,public_repo'
159
+
160
+ config.oauth :facebook, 'APP_ID', 'APP_SECRET',
161
+ :site => 'https://graph.facebook.com/',
162
+ :scope => %w(email offline_access)
163
+
164
+ # ==> Warden configuration
165
+ # If you want to use other strategies, that are not supported by Devise, or
166
+ # change the failure app, you can configure them inside the config.warden block.
167
+ #
168
+ # config.warden do |manager|
169
+ # manager.failure_app = AnotherApp
170
+ # manager.default_strategies(:scope => :user).unshift :some_external_strategy
171
+ # end
172
+ end
@@ -0,0 +1,2 @@
1
+ ActiveSupport::Inflector.inflections do |inflect|
2
+ end
@@ -0,0 +1,2 @@
1
+ Rails.application.config.secret_token = 'ea942c41850d502f2c8283e26bdc57829f471bb18224ddff0a192c4f32cdf6cb5aa0d82b3a7a7adbeb640c4b06f3aa1cd5f098162d8240f669b39d6b49680571'
2
+ Rails.application.config.session_store :cookie_store, :key => "_my_app"
@@ -0,0 +1,54 @@
1
+ Rails.application.routes.draw do
2
+ # Resources for testing
3
+ resources :users, :only => [:index] do
4
+ get :expire, :on => :member
5
+ get :accept, :on => :member
6
+ end
7
+
8
+ resources :admins, :only => [:index]
9
+
10
+ # Users scope
11
+ devise_for :users do
12
+ match "/devise_for/sign_in", :to => "devise/sessions#new"
13
+ end
14
+
15
+ as :user do
16
+ match "/as/sign_in", :to => "devise/sessions#new"
17
+ end
18
+
19
+ match "/sign_in", :to => "devise/sessions#new"
20
+
21
+ # Admin scope
22
+ devise_for :admin, :path => "admin_area", :controllers => { :sessions => "admins/sessions" }, :skip => :passwords
23
+
24
+ match "/admin_area/home", :to => "admins#index", :as => :admin_root
25
+ match "/anywhere", :to => "foo#bar", :as => :new_admin_password
26
+
27
+ authenticate(:admin) do
28
+ match "/private", :to => "home#private", :as => :private
29
+ end
30
+
31
+ # Other routes for routing_test.rb
32
+ namespace :publisher, :path_names => { :sign_in => "i_dont_care", :sign_out => "get_out" } do
33
+ devise_for :accounts, :class_name => "User", :path_names => { :sign_in => "get_in" }
34
+ end
35
+
36
+ scope ":locale" do
37
+ devise_for :accounts, :singular => "manager", :class_name => "User",
38
+ :path_names => {
39
+ :sign_in => "login", :sign_out => "logout",
40
+ :password => "secret", :confirmation => "verification",
41
+ :unlock => "unblock", :sign_up => "register",
42
+ :registration => "management", :cancel => "giveup"
43
+ }
44
+ end
45
+
46
+ namespace :sign_out_via, :module => "devise" do
47
+ devise_for :deletes, :sign_out_via => :delete, :class_name => "User"
48
+ devise_for :posts, :sign_out_via => :post, :class_name => "User"
49
+ devise_for :delete_or_posts, :sign_out_via => [:delete, :post], :class_name => "User"
50
+ end
51
+
52
+ match "/set", :to => "home#set"
53
+ root :to => "home#index"
54
+ end
@@ -0,0 +1,31 @@
1
+ class CreateTables < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :users do |t|
4
+ t.string :username
5
+ t.string :facebook_token
6
+
7
+ t.database_authenticatable :null => false
8
+ t.confirmable
9
+ t.recoverable
10
+ t.rememberable
11
+ t.trackable
12
+ t.lockable
13
+ t.token_authenticatable
14
+ t.timestamps
15
+ end
16
+
17
+ create_table :admins do |t|
18
+ t.database_authenticatable :null => true
19
+ t.encryptable
20
+ t.rememberable :use_salt => false
21
+ t.recoverable
22
+ t.lockable
23
+ t.timestamps
24
+ end
25
+ end
26
+
27
+ def self.down
28
+ drop_table :users
29
+ drop_table :admins
30
+ end
31
+ end