upstream-devise 2.1.0.rc
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +10 -0
- data/.travis.yml +15 -0
- data/CHANGELOG.rdoc +846 -0
- data/Gemfile +35 -0
- data/Gemfile.lock +165 -0
- data/MIT-LICENSE +20 -0
- data/README.md +384 -0
- data/Rakefile +34 -0
- data/app/controllers/devise/confirmations_controller.rb +43 -0
- data/app/controllers/devise/omniauth_callbacks_controller.rb +24 -0
- data/app/controllers/devise/passwords_controller.rb +47 -0
- data/app/controllers/devise/registrations_controller.rb +107 -0
- data/app/controllers/devise/sessions_controller.rb +49 -0
- data/app/controllers/devise/unlocks_controller.rb +44 -0
- data/app/controllers/devise_controller.rb +177 -0
- data/app/helpers/devise_helper.rb +25 -0
- data/app/mailers/devise/mailer.rb +15 -0
- data/app/views/devise/_links.erb +3 -0
- data/app/views/devise/confirmations/new.html.erb +12 -0
- data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
- data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
- data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
- data/app/views/devise/passwords/edit.html.erb +16 -0
- data/app/views/devise/passwords/new.html.erb +12 -0
- data/app/views/devise/registrations/edit.html.erb +25 -0
- data/app/views/devise/registrations/new.html.erb +18 -0
- data/app/views/devise/sessions/new.html.erb +17 -0
- data/app/views/devise/shared/_links.erb +25 -0
- data/app/views/devise/unlocks/new.html.erb +12 -0
- data/config/locales/en.yml +57 -0
- data/devise.gemspec +25 -0
- data/gemfiles/Gemfile.rails-3.1.x +35 -0
- data/gemfiles/Gemfile.rails-3.1.x.lock +167 -0
- data/lib/devise.rb +455 -0
- data/lib/devise/controllers/helpers.rb +269 -0
- data/lib/devise/controllers/rememberable.rb +52 -0
- data/lib/devise/controllers/scoped_views.rb +17 -0
- data/lib/devise/controllers/url_helpers.rb +67 -0
- data/lib/devise/delegator.rb +17 -0
- data/lib/devise/encryptors/authlogic_sha512.rb +19 -0
- data/lib/devise/encryptors/base.rb +24 -0
- data/lib/devise/encryptors/clearance_sha1.rb +17 -0
- data/lib/devise/encryptors/restful_authentication_sha1.rb +22 -0
- data/lib/devise/encryptors/sha1.rb +25 -0
- data/lib/devise/encryptors/sha512.rb +25 -0
- data/lib/devise/failure_app.rb +185 -0
- data/lib/devise/hooks/activatable.rb +11 -0
- data/lib/devise/hooks/forgetable.rb +9 -0
- data/lib/devise/hooks/lockable.rb +7 -0
- data/lib/devise/hooks/rememberable.rb +6 -0
- data/lib/devise/hooks/timeoutable.rb +22 -0
- data/lib/devise/hooks/trackable.rb +9 -0
- data/lib/devise/mailers/helpers.rb +86 -0
- data/lib/devise/mapping.rb +172 -0
- data/lib/devise/models.rb +123 -0
- data/lib/devise/models/authenticatable.rb +231 -0
- data/lib/devise/models/confirmable.rb +242 -0
- data/lib/devise/models/database_authenticatable.rb +126 -0
- data/lib/devise/models/encryptable.rb +86 -0
- data/lib/devise/models/lockable.rb +185 -0
- data/lib/devise/models/omniauthable.rb +27 -0
- data/lib/devise/models/recoverable.rb +140 -0
- data/lib/devise/models/registerable.rb +25 -0
- data/lib/devise/models/rememberable.rb +125 -0
- data/lib/devise/models/timeoutable.rb +49 -0
- data/lib/devise/models/token_authenticatable.rb +77 -0
- data/lib/devise/models/trackable.rb +35 -0
- data/lib/devise/models/validatable.rb +66 -0
- data/lib/devise/modules.rb +30 -0
- data/lib/devise/omniauth.rb +28 -0
- data/lib/devise/omniauth/config.rb +45 -0
- data/lib/devise/omniauth/url_helpers.rb +33 -0
- data/lib/devise/orm/active_record.rb +3 -0
- data/lib/devise/orm/mongoid.rb +3 -0
- data/lib/devise/param_filter.rb +41 -0
- data/lib/devise/rails.rb +54 -0
- data/lib/devise/rails/routes.rb +412 -0
- data/lib/devise/rails/warden_compat.rb +43 -0
- data/lib/devise/strategies/authenticatable.rb +165 -0
- data/lib/devise/strategies/base.rb +15 -0
- data/lib/devise/strategies/database_authenticatable.rb +21 -0
- data/lib/devise/strategies/rememberable.rb +53 -0
- data/lib/devise/strategies/token_authenticatable.rb +57 -0
- data/lib/devise/test_helpers.rb +130 -0
- data/lib/devise/version.rb +3 -0
- data/lib/generators/active_record/devise_generator.rb +78 -0
- data/lib/generators/active_record/templates/migration.rb +19 -0
- data/lib/generators/active_record/templates/migration_existing.rb +26 -0
- data/lib/generators/devise/devise_generator.rb +24 -0
- data/lib/generators/devise/install_generator.rb +24 -0
- data/lib/generators/devise/orm_helpers.rb +32 -0
- data/lib/generators/devise/views_generator.rb +110 -0
- data/lib/generators/mongoid/devise_generator.rb +60 -0
- data/lib/generators/templates/README +31 -0
- data/lib/generators/templates/devise.rb +216 -0
- data/lib/generators/templates/markerb/confirmation_instructions.markerb +5 -0
- data/lib/generators/templates/markerb/reset_password_instructions.markerb +8 -0
- data/lib/generators/templates/markerb/unlock_instructions.markerb +7 -0
- data/lib/generators/templates/simple_form_for/confirmations/new.html.erb +15 -0
- data/lib/generators/templates/simple_form_for/passwords/edit.html.erb +19 -0
- data/lib/generators/templates/simple_form_for/passwords/new.html.erb +15 -0
- data/lib/generators/templates/simple_form_for/registrations/edit.html.erb +22 -0
- data/lib/generators/templates/simple_form_for/registrations/new.html.erb +17 -0
- data/lib/generators/templates/simple_form_for/sessions/new.html.erb +15 -0
- data/lib/generators/templates/simple_form_for/unlocks/new.html.erb +15 -0
- data/test/controllers/custom_strategy_test.rb +62 -0
- data/test/controllers/helpers_test.rb +254 -0
- data/test/controllers/internal_helpers_test.rb +97 -0
- data/test/controllers/sessions_controller_test.rb +36 -0
- data/test/controllers/url_helpers_test.rb +59 -0
- data/test/delegator_test.rb +19 -0
- data/test/devise_test.rb +72 -0
- data/test/encryptors_test.rb +30 -0
- data/test/failure_app_test.rb +211 -0
- data/test/generators/active_record_generator_test.rb +69 -0
- data/test/generators/devise_generator_test.rb +39 -0
- data/test/generators/install_generator_test.rb +13 -0
- data/test/generators/mongoid_generator_test.rb +23 -0
- data/test/generators/views_generator_test.rb +52 -0
- data/test/helpers/devise_helper_test.rb +51 -0
- data/test/indifferent_hash.rb +33 -0
- data/test/integration/authenticatable_test.rb +587 -0
- data/test/integration/confirmable_test.rb +255 -0
- data/test/integration/database_authenticatable_test.rb +82 -0
- data/test/integration/http_authenticatable_test.rb +97 -0
- data/test/integration/lockable_test.rb +224 -0
- data/test/integration/omniauthable_test.rb +133 -0
- data/test/integration/recoverable_test.rb +300 -0
- data/test/integration/registerable_test.rb +324 -0
- data/test/integration/rememberable_test.rb +158 -0
- data/test/integration/timeoutable_test.rb +114 -0
- data/test/integration/token_authenticatable_test.rb +161 -0
- data/test/integration/trackable_test.rb +92 -0
- data/test/mailers/confirmation_instructions_test.rb +95 -0
- data/test/mailers/reset_password_instructions_test.rb +83 -0
- data/test/mailers/unlock_instructions_test.rb +77 -0
- data/test/mapping_test.rb +127 -0
- data/test/models/authenticatable_test.rb +7 -0
- data/test/models/confirmable_test.rb +357 -0
- data/test/models/database_authenticatable_test.rb +189 -0
- data/test/models/encryptable_test.rb +73 -0
- data/test/models/lockable_test.rb +263 -0
- data/test/models/omniauthable_test.rb +7 -0
- data/test/models/recoverable_test.rb +205 -0
- data/test/models/registerable_test.rb +7 -0
- data/test/models/rememberable_test.rb +174 -0
- data/test/models/serializable_test.rb +48 -0
- data/test/models/timeoutable_test.rb +46 -0
- data/test/models/token_authenticatable_test.rb +55 -0
- data/test/models/trackable_test.rb +13 -0
- data/test/models/validatable_test.rb +117 -0
- data/test/models_test.rb +179 -0
- data/test/omniauth/config_test.rb +57 -0
- data/test/omniauth/url_helpers_test.rb +58 -0
- data/test/orm/active_record.rb +9 -0
- data/test/orm/mongoid.rb +14 -0
- data/test/rails_app/Rakefile +10 -0
- data/test/rails_app/app/active_record/admin.rb +6 -0
- data/test/rails_app/app/active_record/shim.rb +2 -0
- data/test/rails_app/app/active_record/user.rb +6 -0
- data/test/rails_app/app/controllers/admins/sessions_controller.rb +6 -0
- data/test/rails_app/app/controllers/admins_controller.rb +6 -0
- data/test/rails_app/app/controllers/application_controller.rb +8 -0
- data/test/rails_app/app/controllers/home_controller.rb +25 -0
- data/test/rails_app/app/controllers/publisher/registrations_controller.rb +2 -0
- data/test/rails_app/app/controllers/publisher/sessions_controller.rb +2 -0
- data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +14 -0
- data/test/rails_app/app/controllers/users_controller.rb +23 -0
- data/test/rails_app/app/helpers/application_helper.rb +3 -0
- data/test/rails_app/app/mailers/users/mailer.rb +3 -0
- data/test/rails_app/app/mongoid/admin.rb +30 -0
- data/test/rails_app/app/mongoid/shim.rb +24 -0
- data/test/rails_app/app/mongoid/user.rb +45 -0
- data/test/rails_app/app/views/admins/index.html.erb +1 -0
- data/test/rails_app/app/views/admins/sessions/new.html.erb +2 -0
- data/test/rails_app/app/views/home/admin_dashboard.html.erb +1 -0
- data/test/rails_app/app/views/home/index.html.erb +1 -0
- data/test/rails_app/app/views/home/join.html.erb +1 -0
- data/test/rails_app/app/views/home/private.html.erb +1 -0
- data/test/rails_app/app/views/home/user_dashboard.html.erb +1 -0
- data/test/rails_app/app/views/layouts/application.html.erb +24 -0
- data/test/rails_app/app/views/users/index.html.erb +1 -0
- data/test/rails_app/app/views/users/mailer/confirmation_instructions.erb +1 -0
- data/test/rails_app/app/views/users/sessions/new.html.erb +1 -0
- data/test/rails_app/config.ru +4 -0
- data/test/rails_app/config/application.rb +41 -0
- data/test/rails_app/config/boot.rb +8 -0
- data/test/rails_app/config/database.yml +18 -0
- data/test/rails_app/config/environment.rb +5 -0
- data/test/rails_app/config/environments/development.rb +18 -0
- data/test/rails_app/config/environments/production.rb +33 -0
- data/test/rails_app/config/environments/test.rb +33 -0
- data/test/rails_app/config/initializers/backtrace_silencers.rb +7 -0
- data/test/rails_app/config/initializers/devise.rb +186 -0
- data/test/rails_app/config/initializers/inflections.rb +2 -0
- data/test/rails_app/config/initializers/secret_token.rb +2 -0
- data/test/rails_app/config/routes.rb +90 -0
- data/test/rails_app/db/migrate/20100401102949_create_tables.rb +77 -0
- data/test/rails_app/db/schema.rb +52 -0
- data/test/rails_app/lib/shared_admin.rb +14 -0
- data/test/rails_app/lib/shared_user.rb +26 -0
- data/test/rails_app/public/404.html +26 -0
- data/test/rails_app/public/422.html +26 -0
- data/test/rails_app/public/500.html +26 -0
- data/test/rails_app/public/favicon.ico +0 -0
- data/test/rails_app/script/rails +10 -0
- data/test/routes_test.rb +248 -0
- data/test/support/assertions.rb +42 -0
- data/test/support/helpers.rb +91 -0
- data/test/support/integration.rb +90 -0
- data/test/support/locale/en.yml +4 -0
- data/test/support/webrat/integrations/rails.rb +24 -0
- data/test/test_helper.rb +27 -0
- data/test/test_helpers_test.rb +134 -0
- metadata +451 -0
@@ -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,186 @@
|
|
1
|
+
require "omniauth-facebook"
|
2
|
+
require "omniauth-openid"
|
3
|
+
|
4
|
+
# Use this hook to configure devise mailer, warden hooks and so forth. The first
|
5
|
+
# four configuration values can also be set straight in your models.
|
6
|
+
Devise.setup do |config|
|
7
|
+
# ==> Mailer Configuration
|
8
|
+
# Configure the e-mail address which will be shown in Devise::Mailer,
|
9
|
+
# note that it will be overwritten if you use your own mailer class with default "from" parameter.
|
10
|
+
config.mailer_sender = "please-change-me@config-initializers-devise.com"
|
11
|
+
|
12
|
+
# Configure the class responsible to send e-mails.
|
13
|
+
# config.mailer = "Devise::Mailer"
|
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/#{DEVISE_ORM}"
|
20
|
+
|
21
|
+
# ==> Configuration for any authentication mechanism
|
22
|
+
# Configure which keys are used when authenticating a user. By 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 hash where the value is a boolean expliciting if authentication
|
28
|
+
# should be aborted or not if the value is not present. By default is empty.
|
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
|
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 = true
|
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
|
+
# ==> Configuration for :database_authenticatable
|
61
|
+
# For bcrypt, this is the cost for hashing the password and defaults to 10. If
|
62
|
+
# using other encryptors, it sets how many times you want the password re-encrypted.
|
63
|
+
config.stretches = Rails.env.test? ? 1 : 10
|
64
|
+
|
65
|
+
# ==> Configuration for :confirmable
|
66
|
+
# The time you want to give your user to confirm his account. During this time
|
67
|
+
# he will be able to access your application without confirming. Default is nil.
|
68
|
+
# When allow_unconfirmed_access_for is zero, the user won't be able to sign in without confirming.
|
69
|
+
# You can use this to let your user access some features of your application
|
70
|
+
# without confirming the account, but blocking it after a certain period
|
71
|
+
# (ie 2 days).
|
72
|
+
# config.allow_unconfirmed_access_for = 2.days
|
73
|
+
|
74
|
+
# Defines which key will be used when confirming an account
|
75
|
+
# config.confirmation_keys = [ :email ]
|
76
|
+
|
77
|
+
# ==> Configuration for :rememberable
|
78
|
+
# The time the user will be remembered without asking for credentials again.
|
79
|
+
# config.remember_for = 2.weeks
|
80
|
+
|
81
|
+
# If true, a valid remember token can be re-used between multiple browsers.
|
82
|
+
# config.remember_across_browsers = true
|
83
|
+
|
84
|
+
# If true, extends the user's remember period when remembered via cookie.
|
85
|
+
# config.extend_remember_period = false
|
86
|
+
|
87
|
+
# ==> Configuration for :validatable
|
88
|
+
# Range for password length. Default is 6..128.
|
89
|
+
# config.password_length = 6..128
|
90
|
+
|
91
|
+
# Regex to use to validate the email address
|
92
|
+
# config.email_regexp = /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i
|
93
|
+
|
94
|
+
# ==> Configuration for :timeoutable
|
95
|
+
# The time you want to timeout the user session without activity. After this
|
96
|
+
# time the user will be asked for credentials again. Default is 30 minutes.
|
97
|
+
# config.timeout_in = 30.minutes
|
98
|
+
|
99
|
+
# ==> Configuration for :lockable
|
100
|
+
# Defines which strategy will be used to lock an account.
|
101
|
+
# :failed_attempts = Locks an account after a number of failed attempts to sign in.
|
102
|
+
# :none = No lock strategy. You should handle locking by yourself.
|
103
|
+
# config.lock_strategy = :failed_attempts
|
104
|
+
|
105
|
+
# Defines which key will be used when locking and unlocking an account
|
106
|
+
# config.unlock_keys = [ :email ]
|
107
|
+
|
108
|
+
# Defines which strategy will be used to unlock an account.
|
109
|
+
# :email = Sends an unlock link to the user email
|
110
|
+
# :time = Re-enables login after a certain amount of time (see :unlock_in below)
|
111
|
+
# :both = Enables both strategies
|
112
|
+
# :none = No unlock strategy. You should handle unlocking by yourself.
|
113
|
+
# config.unlock_strategy = :both
|
114
|
+
|
115
|
+
# Number of authentication tries before locking an account if lock_strategy
|
116
|
+
# is failed attempts.
|
117
|
+
# config.maximum_attempts = 20
|
118
|
+
|
119
|
+
# Time interval to unlock the account if :time is enabled as unlock_strategy.
|
120
|
+
# config.unlock_in = 1.hour
|
121
|
+
|
122
|
+
# ==> Configuration for :recoverable
|
123
|
+
#
|
124
|
+
# Defines which key will be used when recovering the password for an account
|
125
|
+
# config.reset_password_keys = [ :email ]
|
126
|
+
|
127
|
+
# Time interval you can reset your password with a reset password key.
|
128
|
+
# Don't put a too small interval or your users won't have the time to
|
129
|
+
# change their passwords.
|
130
|
+
config.reset_password_within = 2.hours
|
131
|
+
|
132
|
+
# ==> Configuration for :encryptable
|
133
|
+
# Allow you to use another encryption algorithm besides bcrypt (default). You can use
|
134
|
+
# :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
|
135
|
+
# :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
|
136
|
+
# and :restful_authentication_sha1 (then you should set stretches to 10, and copy
|
137
|
+
# REST_AUTH_SITE_KEY to pepper)
|
138
|
+
config.encryptor = :sha512
|
139
|
+
|
140
|
+
# Setup a pepper to generate the encrypted password.
|
141
|
+
config.pepper = "d142367154e5beacca404b1a6a4f8bc52c6fdcfa3ccc3cf8eb49f3458a688ee6ac3b9fae488432a3bfca863b8a90008368a9f3a3dfbe5a962e64b6ab8f3a3a1a"
|
142
|
+
|
143
|
+
# ==> Configuration for :token_authenticatable
|
144
|
+
# Defines name of the authentication token params key
|
145
|
+
# config.token_authentication_key = :auth_token
|
146
|
+
|
147
|
+
# ==> Scopes configuration
|
148
|
+
# Turn scoped views on. Before rendering "sessions/new", it will first check for
|
149
|
+
# "users/sessions/new". It's turned off by default because it's slower if you
|
150
|
+
# are using only default views.
|
151
|
+
# config.scoped_views = false
|
152
|
+
|
153
|
+
# Configure the default scope given to Warden. By default it's the first
|
154
|
+
# devise role declared in your routes (usually :user).
|
155
|
+
# config.default_scope = :user
|
156
|
+
|
157
|
+
# Configure sign_out behavior.
|
158
|
+
# Sign_out action can be scoped (i.e. /users/sign_out affects only :user scope).
|
159
|
+
# The default is true, which means any logout action will sign out all active scopes.
|
160
|
+
# config.sign_out_all_scopes = true
|
161
|
+
|
162
|
+
# ==> Navigation configuration
|
163
|
+
# Lists the formats that should be treated as navigational. Formats like
|
164
|
+
# :html, should redirect to the sign in page when the user does not have
|
165
|
+
# access, but formats like :xml or :json, should return 401.
|
166
|
+
# If you have any extra navigational formats, like :iphone or :mobile, you
|
167
|
+
# should add them to the navigational formats lists. Default is [:html]
|
168
|
+
# config.navigational_formats = [:html, :iphone]
|
169
|
+
|
170
|
+
# The default HTTP method used to sign out a resource. Default is :get.
|
171
|
+
# config.sign_out_via = :get
|
172
|
+
|
173
|
+
# ==> OmniAuth
|
174
|
+
config.omniauth :facebook, 'APP_ID', 'APP_SECRET', :scope => 'email,offline_access'
|
175
|
+
config.omniauth :openid
|
176
|
+
config.omniauth :openid, :name => 'google', :identifier => 'https://www.google.com/accounts/o8/id'
|
177
|
+
|
178
|
+
# ==> Warden configuration
|
179
|
+
# If you want to use other strategies, that are not supported by Devise, or
|
180
|
+
# change the failure app, you can configure them inside the config.warden block.
|
181
|
+
#
|
182
|
+
# config.warden do |manager|
|
183
|
+
# manager.failure_app = AnotherApp
|
184
|
+
# manager.default_strategies(:scope => :user).unshift :some_external_strategy
|
185
|
+
# end
|
186
|
+
end
|
@@ -0,0 +1,90 @@
|
|
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
|
+
|
7
|
+
authenticate do
|
8
|
+
post :exhibit, :on => :member
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
resources :admins, :only => [:index]
|
13
|
+
|
14
|
+
# Users scope
|
15
|
+
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }
|
16
|
+
|
17
|
+
as :user do
|
18
|
+
match "/as/sign_in", :to => "devise/sessions#new"
|
19
|
+
end
|
20
|
+
|
21
|
+
match "/sign_in", :to => "devise/sessions#new"
|
22
|
+
|
23
|
+
# Admin scope
|
24
|
+
devise_for :admin, :path => "admin_area", :controllers => { :sessions => :"admins/sessions" }, :skip => :passwords
|
25
|
+
|
26
|
+
match "/admin_area/home", :to => "admins#index", :as => :admin_root
|
27
|
+
match "/anywhere", :to => "foo#bar", :as => :new_admin_password
|
28
|
+
|
29
|
+
authenticate(:admin) do
|
30
|
+
match "/private", :to => "home#private", :as => :private
|
31
|
+
end
|
32
|
+
|
33
|
+
authenticated :admin do
|
34
|
+
match "/dashboard", :to => "home#admin_dashboard"
|
35
|
+
end
|
36
|
+
|
37
|
+
authenticated do
|
38
|
+
match "/dashboard", :to => "home#user_dashboard"
|
39
|
+
end
|
40
|
+
|
41
|
+
unauthenticated do
|
42
|
+
match "/join", :to => "home#join"
|
43
|
+
end
|
44
|
+
|
45
|
+
# Routes for constraints testing
|
46
|
+
devise_for :headquarters_admin, :class_name => "Admin", :path => "headquarters", :constraints => {:host => /192\.168\.1\.\d\d\d/}
|
47
|
+
|
48
|
+
constraints(:host => /192\.168\.1\.\d\d\d/) do
|
49
|
+
devise_for :homebase_admin, :class_name => "Admin", :path => "homebase"
|
50
|
+
end
|
51
|
+
|
52
|
+
devise_for :skip_admin, :class_name => "Admin", :skip => :all
|
53
|
+
|
54
|
+
# Routes for format=false testing
|
55
|
+
devise_for :htmlonly_admin, :class_name => "Admin", :skip => [:confirmations, :unlocks], :path => "htmlonly_admin", :format => false, :skip_helpers => [:confirmations, :unlocks]
|
56
|
+
devise_for :htmlonly_users, :class_name => "User", :only => [:confirmations, :unlocks], :path => "htmlonly_users", :format => false, :skip_helpers => true
|
57
|
+
|
58
|
+
# Other routes for routing_test.rb
|
59
|
+
devise_for :reader, :class_name => "User", :only => :passwords
|
60
|
+
|
61
|
+
scope :host => "sub.example.com" do
|
62
|
+
devise_for :sub_admin, :class_name => "Admin"
|
63
|
+
end
|
64
|
+
|
65
|
+
namespace :publisher, :path_names => { :sign_in => "i_dont_care", :sign_out => "get_out" } do
|
66
|
+
devise_for :accounts, :class_name => "Admin", :path_names => { :sign_in => "get_in" }
|
67
|
+
end
|
68
|
+
|
69
|
+
scope ":locale", :module => :invalid do
|
70
|
+
devise_for :accounts, :singular => "manager", :class_name => "Admin",
|
71
|
+
:path_names => {
|
72
|
+
:sign_in => "login", :sign_out => "logout",
|
73
|
+
:password => "secret", :confirmation => "verification",
|
74
|
+
:unlock => "unblock", :sign_up => "register",
|
75
|
+
:registration => "management", :cancel => "giveup"
|
76
|
+
}, :failure_app => lambda { |env| [404, {"Content-Type" => "text/plain"}, ["Oops, not found"]] }, :module => :devise
|
77
|
+
end
|
78
|
+
|
79
|
+
namespace :sign_out_via, :module => "devise" do
|
80
|
+
devise_for :deletes, :sign_out_via => :delete, :class_name => "Admin"
|
81
|
+
devise_for :posts, :sign_out_via => :post, :class_name => "Admin"
|
82
|
+
devise_for :delete_or_posts, :sign_out_via => [:delete, :post], :class_name => "Admin"
|
83
|
+
end
|
84
|
+
|
85
|
+
match "/set", :to => "home#set"
|
86
|
+
match "/unauthenticated", :to => "home#unauthenticated"
|
87
|
+
match "/custom_strategy/new"
|
88
|
+
|
89
|
+
root :to => "home#index"
|
90
|
+
end
|
@@ -0,0 +1,77 @@
|
|
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
|
+
## Database authenticatable
|
8
|
+
t.string :email, :null => false, :default => ""
|
9
|
+
t.string :encrypted_password, :null => false, :default => ""
|
10
|
+
|
11
|
+
## Recoverable
|
12
|
+
t.string :reset_password_token
|
13
|
+
t.datetime :reset_password_sent_at
|
14
|
+
|
15
|
+
## Rememberable
|
16
|
+
t.datetime :remember_created_at
|
17
|
+
|
18
|
+
## Trackable
|
19
|
+
t.integer :sign_in_count, :default => 0
|
20
|
+
t.datetime :current_sign_in_at
|
21
|
+
t.datetime :last_sign_in_at
|
22
|
+
t.string :current_sign_in_ip
|
23
|
+
t.string :last_sign_in_ip
|
24
|
+
|
25
|
+
## Encryptable
|
26
|
+
# t.string :password_salt
|
27
|
+
|
28
|
+
## Confirmable
|
29
|
+
t.string :confirmation_token
|
30
|
+
t.datetime :confirmed_at
|
31
|
+
t.datetime :confirmation_sent_at
|
32
|
+
# t.string :unconfirmed_email # Only if using reconfirmable
|
33
|
+
|
34
|
+
## Lockable
|
35
|
+
t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
|
36
|
+
t.string :unlock_token # Only if unlock strategy is :email or :both
|
37
|
+
t.datetime :locked_at
|
38
|
+
|
39
|
+
## Token authenticatable
|
40
|
+
t.string :authentication_token
|
41
|
+
|
42
|
+
t.timestamps
|
43
|
+
end
|
44
|
+
|
45
|
+
create_table :admins do |t|
|
46
|
+
## Database authenticatable
|
47
|
+
t.string :email, :null => true
|
48
|
+
t.string :encrypted_password, :null => true
|
49
|
+
|
50
|
+
## Recoverable
|
51
|
+
t.string :reset_password_token
|
52
|
+
t.datetime :reset_password_sent_at
|
53
|
+
|
54
|
+
## Rememberable
|
55
|
+
t.datetime :remember_created_at
|
56
|
+
|
57
|
+
## Confirmable
|
58
|
+
t.string :confirmation_token
|
59
|
+
t.datetime :confirmed_at
|
60
|
+
t.datetime :confirmation_sent_at
|
61
|
+
t.string :unconfirmed_email # Only if using reconfirmable
|
62
|
+
|
63
|
+
## Encryptable
|
64
|
+
t.string :password_salt
|
65
|
+
|
66
|
+
## Lockable
|
67
|
+
t.datetime :locked_at
|
68
|
+
|
69
|
+
t.timestamps
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.down
|
74
|
+
drop_table :users
|
75
|
+
drop_table :admins
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# This file is auto-generated from the current state of the database. Instead
|
2
|
+
# of editing this file, please use the migrations feature of Active Record to
|
3
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
4
|
+
#
|
5
|
+
# Note that this schema.rb definition is the authoritative source for your
|
6
|
+
# database schema. If you need to create the application database on another
|
7
|
+
# system, you should be using db:schema:load, not running all the migrations
|
8
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
9
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
10
|
+
#
|
11
|
+
# It's strongly recommended to check this file into your version control system.
|
12
|
+
|
13
|
+
ActiveRecord::Schema.define(:version => 20100401102949) do
|
14
|
+
|
15
|
+
create_table "admins", :force => true do |t|
|
16
|
+
t.string "email"
|
17
|
+
t.string "encrypted_password", :limit => 128
|
18
|
+
t.string "password_salt"
|
19
|
+
t.string "remember_token"
|
20
|
+
t.datetime "remember_created_at"
|
21
|
+
t.string "reset_password_token"
|
22
|
+
t.integer "failed_attempts", :default => 0
|
23
|
+
t.string "unlock_token"
|
24
|
+
t.datetime "locked_at"
|
25
|
+
t.datetime "created_at"
|
26
|
+
t.datetime "updated_at"
|
27
|
+
end
|
28
|
+
|
29
|
+
create_table "users", :force => true do |t|
|
30
|
+
t.string "username"
|
31
|
+
t.string "facebook_token"
|
32
|
+
t.string "email", :default => "", :null => false
|
33
|
+
t.string "encrypted_password", :limit => 128, :default => "", :null => false
|
34
|
+
t.string "confirmation_token"
|
35
|
+
t.datetime "confirmed_at"
|
36
|
+
t.datetime "confirmation_sent_at"
|
37
|
+
t.string "reset_password_token"
|
38
|
+
t.datetime "remember_created_at"
|
39
|
+
t.integer "sign_in_count", :default => 0
|
40
|
+
t.datetime "current_sign_in_at"
|
41
|
+
t.datetime "last_sign_in_at"
|
42
|
+
t.string "current_sign_in_ip"
|
43
|
+
t.string "last_sign_in_ip"
|
44
|
+
t.integer "failed_attempts", :default => 0
|
45
|
+
t.string "unlock_token"
|
46
|
+
t.datetime "locked_at"
|
47
|
+
t.string "authentication_token"
|
48
|
+
t.datetime "created_at"
|
49
|
+
t.datetime "updated_at"
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|