devise-jdguyot 1.2.rc
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.
- data/.gitignore +10 -0
- data/CHANGELOG.rdoc +532 -0
- data/Gemfile +29 -0
- data/Gemfile.lock +152 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +353 -0
- data/Rakefile +36 -0
- data/TODO +4 -0
- data/app/controllers/devise/confirmations_controller.rb +33 -0
- data/app/controllers/devise/omniauth_callbacks_controller.rb +26 -0
- data/app/controllers/devise/passwords_controller.rb +41 -0
- data/app/controllers/devise/registrations_controller.rb +110 -0
- data/app/controllers/devise/sessions_controller.rb +25 -0
- data/app/controllers/devise/unlocks_controller.rb +34 -0
- data/app/helpers/devise_helper.rb +19 -0
- data/app/mailers/devise/mailer.rb +88 -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 +46 -0
- data/devise.gemspec +25 -0
- data/lib/devise/controllers/helpers.rb +227 -0
- data/lib/devise/controllers/internal_helpers.rb +119 -0
- data/lib/devise/controllers/scoped_views.rb +33 -0
- data/lib/devise/controllers/url_helpers.rb +39 -0
- data/lib/devise/encryptors/authlogic_sha512.rb +19 -0
- data/lib/devise/encryptors/base.rb +20 -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 +132 -0
- data/lib/devise/hooks/activatable.rb +11 -0
- data/lib/devise/hooks/forgetable.rb +12 -0
- data/lib/devise/hooks/rememberable.rb +48 -0
- data/lib/devise/hooks/timeoutable.rb +22 -0
- data/lib/devise/hooks/trackable.rb +9 -0
- data/lib/devise/mapping.rb +110 -0
- data/lib/devise/models/authenticatable.rb +146 -0
- data/lib/devise/models/confirmable.rb +160 -0
- data/lib/devise/models/database_authenticatable.rb +100 -0
- data/lib/devise/models/encryptable.rb +72 -0
- data/lib/devise/models/lockable.rb +169 -0
- data/lib/devise/models/omniauthable.rb +23 -0
- data/lib/devise/models/recoverable.rb +123 -0
- data/lib/devise/models/registerable.rb +21 -0
- data/lib/devise/models/rememberable.rb +130 -0
- data/lib/devise/models/timeoutable.rb +43 -0
- data/lib/devise/models/token_authenticatable.rb +72 -0
- data/lib/devise/models/trackable.rb +30 -0
- data/lib/devise/models/validatable.rb +65 -0
- data/lib/devise/models.rb +68 -0
- data/lib/devise/modules.rb +30 -0
- data/lib/devise/omniauth/config.rb +30 -0
- data/lib/devise/omniauth/test_helpers.rb +57 -0
- data/lib/devise/omniauth/url_helpers.rb +29 -0
- data/lib/devise/omniauth.rb +47 -0
- data/lib/devise/orm/active_record.rb +38 -0
- data/lib/devise/orm/mongoid.rb +31 -0
- data/lib/devise/path_checker.rb +18 -0
- data/lib/devise/rails/routes.rb +292 -0
- data/lib/devise/rails/warden_compat.rb +125 -0
- data/lib/devise/rails.rb +50 -0
- data/lib/devise/schema.rb +97 -0
- data/lib/devise/strategies/authenticatable.rb +150 -0
- data/lib/devise/strategies/base.rb +15 -0
- data/lib/devise/strategies/database_authenticatable.rb +21 -0
- data/lib/devise/strategies/rememberable.rb +51 -0
- data/lib/devise/strategies/token_authenticatable.rb +53 -0
- data/lib/devise/test_helpers.rb +100 -0
- data/lib/devise/version.rb +3 -0
- data/lib/devise.rb +381 -0
- data/lib/generators/active_record/devise_generator.rb +28 -0
- data/lib/generators/active_record/templates/migration.rb +31 -0
- data/lib/generators/devise/devise_generator.rb +17 -0
- data/lib/generators/devise/install_generator.rb +24 -0
- data/lib/generators/devise/orm_helpers.rb +23 -0
- data/lib/generators/devise/views_generator.rb +106 -0
- data/lib/generators/mongoid/devise_generator.rb +17 -0
- data/lib/generators/templates/README +25 -0
- data/lib/generators/templates/devise.rb +186 -0
- data/test/controllers/helpers_test.rb +237 -0
- data/test/controllers/internal_helpers_test.rb +72 -0
- data/test/controllers/url_helpers_test.rb +59 -0
- data/test/devise_test.rb +65 -0
- data/test/encryptors_test.rb +30 -0
- data/test/failure_app_test.rb +187 -0
- data/test/generators/active_record_generator_test.rb +24 -0
- data/test/generators/install_generator_test.rb +13 -0
- data/test/generators/mongoid_generator_test.rb +22 -0
- data/test/generators/views_generator_test.rb +35 -0
- data/test/indifferent_hash.rb +33 -0
- data/test/integration/authenticatable_test.rb +447 -0
- data/test/integration/confirmable_test.rb +104 -0
- data/test/integration/database_authenticatable_test.rb +60 -0
- data/test/integration/http_authenticatable_test.rb +74 -0
- data/test/integration/lockable_test.rb +109 -0
- data/test/integration/omniauthable_test.rb +107 -0
- data/test/integration/recoverable_test.rb +160 -0
- data/test/integration/registerable_test.rb +179 -0
- data/test/integration/rememberable_test.rb +180 -0
- data/test/integration/timeoutable_test.rb +89 -0
- data/test/integration/token_authenticatable_test.rb +99 -0
- data/test/integration/trackable_test.rb +64 -0
- data/test/mailers/confirmation_instructions_test.rb +84 -0
- data/test/mailers/reset_password_instructions_test.rb +72 -0
- data/test/mailers/unlock_instructions_test.rb +66 -0
- data/test/mapping_test.rb +119 -0
- data/test/models/confirmable_test.rb +221 -0
- data/test/models/database_authenticatable_test.rb +98 -0
- data/test/models/encryptable_test.rb +65 -0
- data/test/models/lockable_test.rb +204 -0
- data/test/models/recoverable_test.rb +190 -0
- data/test/models/rememberable_test.rb +279 -0
- data/test/models/timeoutable_test.rb +28 -0
- data/test/models/token_authenticatable_test.rb +37 -0
- data/test/models/trackable_test.rb +5 -0
- data/test/models/validatable_test.rb +99 -0
- data/test/models_test.rb +84 -0
- data/test/omniauth/url_helpers_test.rb +47 -0
- data/test/orm/active_record.rb +9 -0
- data/test/orm/mongoid.rb +11 -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 +8 -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 +16 -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 +7 -0
- data/test/rails_app/app/controllers/users_controller.rb +18 -0
- data/test/rails_app/app/helpers/application_helper.rb +3 -0
- data/test/rails_app/app/mongoid/admin.rb +9 -0
- data/test/rails_app/app/mongoid/shim.rb +29 -0
- data/test/rails_app/app/mongoid/user.rb +10 -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/index.html.erb +1 -0
- data/test/rails_app/app/views/home/private.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/application.rb +40 -0
- data/test/rails_app/config/boot.rb +13 -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 +19 -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 +176 -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 +55 -0
- data/test/rails_app/config.ru +4 -0
- data/test/rails_app/db/migrate/20100401102949_create_tables.rb +31 -0
- data/test/rails_app/db/schema.rb +52 -0
- data/test/rails_app/lib/shared_admin.rb +9 -0
- data/test/rails_app/lib/shared_user.rb +23 -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 +179 -0
- data/test/support/assertions.rb +24 -0
- data/test/support/helpers.rb +60 -0
- data/test/support/integration.rb +88 -0
- data/test/support/locale/en.yml +4 -0
- data/test/support/webrat/integrations/rails.rb +24 -0
- data/test/test_helper.rb +29 -0
- data/test/test_helpers_test.rb +118 -0
- metadata +388 -0
|
@@ -0,0 +1,176 @@
|
|
|
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
|
+
# Configure which authentication keys should be case-insensitive.
|
|
35
|
+
# These keys will be downcased upon creating or modifying a user and when used
|
|
36
|
+
# to authenticate or find a user. Default is :email.
|
|
37
|
+
config.case_insensitive_keys = [ :email ]
|
|
38
|
+
|
|
39
|
+
# Tell if authentication through request.params is enabled. True by default.
|
|
40
|
+
# config.params_authenticatable = true
|
|
41
|
+
|
|
42
|
+
# Tell if authentication through HTTP Basic Auth is enabled. False by default.
|
|
43
|
+
config.http_authenticatable = true
|
|
44
|
+
|
|
45
|
+
# If http headers should be returned for AJAX requests. True by default.
|
|
46
|
+
# config.http_authenticatable_on_xhr = true
|
|
47
|
+
|
|
48
|
+
# The realm used in Http Basic Authentication. "Application" by default.
|
|
49
|
+
# config.http_authentication_realm = "Application"
|
|
50
|
+
|
|
51
|
+
# ==> Configuration for :database_authenticatable
|
|
52
|
+
# For bcrypt, this is the cost for hashing the password and defaults to 10. If
|
|
53
|
+
# using other encryptors, it sets how many times you want the password re-encrypted.
|
|
54
|
+
config.stretches = 10
|
|
55
|
+
|
|
56
|
+
# ==> Configuration for :confirmable
|
|
57
|
+
# The time you want to give your user to confirm his account. During this time
|
|
58
|
+
# he will be able to access your application without confirming. Default is nil.
|
|
59
|
+
# When confirm_within is zero, the user won't be able to sign in without confirming.
|
|
60
|
+
# You can use this to let your user access some features of your application
|
|
61
|
+
# without confirming the account, but blocking it after a certain period
|
|
62
|
+
# (ie 2 days).
|
|
63
|
+
# config.confirm_within = 2.days
|
|
64
|
+
|
|
65
|
+
# ==> Configuration for :rememberable
|
|
66
|
+
# The time the user will be remembered without asking for credentials again.
|
|
67
|
+
# config.remember_for = 2.weeks
|
|
68
|
+
|
|
69
|
+
# If true, a valid remember token can be re-used between multiple browsers.
|
|
70
|
+
# config.remember_across_browsers = true
|
|
71
|
+
|
|
72
|
+
# If true, extends the user's remember period when remembered via cookie.
|
|
73
|
+
# config.extend_remember_period = false
|
|
74
|
+
|
|
75
|
+
# If true, uses the password salt as remember token. This should be turned
|
|
76
|
+
# to false if you are not using database authenticatable.
|
|
77
|
+
config.use_salt_as_remember_token = true
|
|
78
|
+
|
|
79
|
+
# ==> Configuration for :validatable
|
|
80
|
+
# Range for password length. Default is 6..20.
|
|
81
|
+
# config.password_length = 6..20
|
|
82
|
+
|
|
83
|
+
# Regex to use to validate the email address
|
|
84
|
+
# config.email_regexp = /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i
|
|
85
|
+
|
|
86
|
+
# ==> Configuration for :timeoutable
|
|
87
|
+
# The time you want to timeout the user session without activity. After this
|
|
88
|
+
# time the user will be asked for credentials again. Default is 30 minutes.
|
|
89
|
+
# config.timeout_in = 30.minutes
|
|
90
|
+
|
|
91
|
+
# ==> Configuration for :lockable
|
|
92
|
+
# Defines which strategy will be used to lock an account.
|
|
93
|
+
# :failed_attempts = Locks an account after a number of failed attempts to sign in.
|
|
94
|
+
# :none = No lock strategy. You should handle locking by yourself.
|
|
95
|
+
# config.lock_strategy = :failed_attempts
|
|
96
|
+
|
|
97
|
+
# Defines which key will be used when locking and unlocking an account
|
|
98
|
+
# config.unlock_keys = [ :email ]
|
|
99
|
+
|
|
100
|
+
# Defines which strategy will be used to unlock an account.
|
|
101
|
+
# :email = Sends an unlock link to the user email
|
|
102
|
+
# :time = Re-enables login after a certain amount of time (see :unlock_in below)
|
|
103
|
+
# :both = Enables both strategies
|
|
104
|
+
# :none = No unlock strategy. You should handle unlocking by yourself.
|
|
105
|
+
# config.unlock_strategy = :both
|
|
106
|
+
|
|
107
|
+
# Number of authentication tries before locking an account if lock_strategy
|
|
108
|
+
# is failed attempts.
|
|
109
|
+
# config.maximum_attempts = 20
|
|
110
|
+
|
|
111
|
+
# Time interval to unlock the account if :time is enabled as unlock_strategy.
|
|
112
|
+
# config.unlock_in = 1.hour
|
|
113
|
+
|
|
114
|
+
# ==> Configuration for :recoverable
|
|
115
|
+
#
|
|
116
|
+
# Defines which key will be used when recovering the password for an account
|
|
117
|
+
# config.reset_password_keys = [ :email ]
|
|
118
|
+
|
|
119
|
+
# ==> Configuration for :encryptable
|
|
120
|
+
# Allow you to use another encryption algorithm besides bcrypt (default). You can use
|
|
121
|
+
# :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
|
|
122
|
+
# :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
|
|
123
|
+
# and :restful_authentication_sha1 (then you should set stretches to 10, and copy
|
|
124
|
+
# REST_AUTH_SITE_KEY to pepper)
|
|
125
|
+
config.encryptor = :sha512
|
|
126
|
+
|
|
127
|
+
# Setup a pepper to generate the encrypted password.
|
|
128
|
+
config.pepper = "d142367154e5beacca404b1a6a4f8bc52c6fdcfa3ccc3cf8eb49f3458a688ee6ac3b9fae488432a3bfca863b8a90008368a9f3a3dfbe5a962e64b6ab8f3a3a1a"
|
|
129
|
+
|
|
130
|
+
# ==> Configuration for :token_authenticatable
|
|
131
|
+
# Defines name of the authentication token params key
|
|
132
|
+
# config.token_authentication_key = :auth_token
|
|
133
|
+
|
|
134
|
+
# If true, authentication through token does not store user in session and needs
|
|
135
|
+
# to be supplied on each request. Useful if you are using the token as API token.
|
|
136
|
+
# config.stateless_token = false
|
|
137
|
+
|
|
138
|
+
# ==> Scopes configuration
|
|
139
|
+
# Turn scoped views on. Before rendering "sessions/new", it will first check for
|
|
140
|
+
# "users/sessions/new". It's turned off by default because it's slower if you
|
|
141
|
+
# are using only default views.
|
|
142
|
+
# config.scoped_views = false
|
|
143
|
+
|
|
144
|
+
# Configure the default scope given to Warden. By default it's the first
|
|
145
|
+
# devise role declared in your routes (usually :user).
|
|
146
|
+
# config.default_scope = :user
|
|
147
|
+
|
|
148
|
+
# Configure sign_out behavior.
|
|
149
|
+
# Sign_out action can be scoped (i.e. /users/sign_out affects only :user scope).
|
|
150
|
+
# The default is true, which means any logout action will sign out all active scopes.
|
|
151
|
+
# config.sign_out_all_scopes = true
|
|
152
|
+
|
|
153
|
+
# ==> Navigation configuration
|
|
154
|
+
# Lists the formats that should be treated as navigational. Formats like
|
|
155
|
+
# :html, should redirect to the sign in page when the user does not have
|
|
156
|
+
# access, but formats like :xml or :json, should return 401.
|
|
157
|
+
# If you have any extra navigational formats, like :iphone or :mobile, you
|
|
158
|
+
# should add them to the navigational formats lists. Default is [:html]
|
|
159
|
+
# config.navigational_formats = [:html, :iphone]
|
|
160
|
+
|
|
161
|
+
# The default HTTP method used to sign out a resource. Default is :get.
|
|
162
|
+
# config.sign_out_via = :get
|
|
163
|
+
|
|
164
|
+
# ==> OmniAuth
|
|
165
|
+
config.omniauth :facebook, 'APP_ID', 'APP_SECRET', :scope => 'email,offline_access'
|
|
166
|
+
config.omniauth :open_id
|
|
167
|
+
|
|
168
|
+
# ==> Warden configuration
|
|
169
|
+
# If you want to use other strategies, that are not supported by Devise, or
|
|
170
|
+
# change the failure app, you can configure them inside the config.warden block.
|
|
171
|
+
#
|
|
172
|
+
# config.warden do |manager|
|
|
173
|
+
# manager.failure_app = AnotherApp
|
|
174
|
+
# manager.default_strategies(:scope => :user).unshift :some_external_strategy
|
|
175
|
+
# end
|
|
176
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
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, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" } 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 => "Admin", :path_names => { :sign_in => "get_in" }
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
scope ":locale" do
|
|
37
|
+
devise_for :accounts, :singular => "manager", :class_name => "Admin",
|
|
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 => "Admin"
|
|
48
|
+
devise_for :posts, :sign_out_via => :post, :class_name => "Admin"
|
|
49
|
+
devise_for :delete_or_posts, :sign_out_via => [:delete, :post], :class_name => "Admin"
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
match "/set", :to => "home#set"
|
|
53
|
+
match "/unauthenticated", :to => "home#unauthenticated"
|
|
54
|
+
root :to => "home#index"
|
|
55
|
+
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
|
|
@@ -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
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module SharedUser
|
|
2
|
+
extend ActiveSupport::Concern
|
|
3
|
+
|
|
4
|
+
included do
|
|
5
|
+
devise :database_authenticatable, :confirmable, :lockable, :recoverable,
|
|
6
|
+
:registerable, :rememberable, :timeoutable, :token_authenticatable,
|
|
7
|
+
:trackable, :validatable, :omniauthable
|
|
8
|
+
|
|
9
|
+
# They need to be included after Devise is called.
|
|
10
|
+
extend ExtendMethods
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
module ExtendMethods
|
|
14
|
+
def new_with_session(params, session)
|
|
15
|
+
super.tap do |user|
|
|
16
|
+
if data = session["devise.facebook_data"]
|
|
17
|
+
user.email = data["email"]
|
|
18
|
+
user.confirmed_at = Time.now
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
|
5
|
+
<style type="text/css">
|
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
|
7
|
+
div.dialog {
|
|
8
|
+
width: 25em;
|
|
9
|
+
padding: 0 4em;
|
|
10
|
+
margin: 4em auto 0 auto;
|
|
11
|
+
border: 1px solid #ccc;
|
|
12
|
+
border-right-color: #999;
|
|
13
|
+
border-bottom-color: #999;
|
|
14
|
+
}
|
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
|
16
|
+
</style>
|
|
17
|
+
</head>
|
|
18
|
+
|
|
19
|
+
<body>
|
|
20
|
+
<!-- This file lives in public/404.html -->
|
|
21
|
+
<div class="dialog">
|
|
22
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
|
23
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
|
24
|
+
</div>
|
|
25
|
+
</body>
|
|
26
|
+
</html>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
|
5
|
+
<style type="text/css">
|
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
|
7
|
+
div.dialog {
|
|
8
|
+
width: 25em;
|
|
9
|
+
padding: 0 4em;
|
|
10
|
+
margin: 4em auto 0 auto;
|
|
11
|
+
border: 1px solid #ccc;
|
|
12
|
+
border-right-color: #999;
|
|
13
|
+
border-bottom-color: #999;
|
|
14
|
+
}
|
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
|
16
|
+
</style>
|
|
17
|
+
</head>
|
|
18
|
+
|
|
19
|
+
<body>
|
|
20
|
+
<!-- This file lives in public/422.html -->
|
|
21
|
+
<div class="dialog">
|
|
22
|
+
<h1>The change you wanted was rejected.</h1>
|
|
23
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
|
24
|
+
</div>
|
|
25
|
+
</body>
|
|
26
|
+
</html>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
|
5
|
+
<style type="text/css">
|
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
|
7
|
+
div.dialog {
|
|
8
|
+
width: 25em;
|
|
9
|
+
padding: 0 4em;
|
|
10
|
+
margin: 4em auto 0 auto;
|
|
11
|
+
border: 1px solid #ccc;
|
|
12
|
+
border-right-color: #999;
|
|
13
|
+
border-bottom-color: #999;
|
|
14
|
+
}
|
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
|
16
|
+
</style>
|
|
17
|
+
</head>
|
|
18
|
+
|
|
19
|
+
<body>
|
|
20
|
+
<!-- This file lives in public/500.html -->
|
|
21
|
+
<div class="dialog">
|
|
22
|
+
<h1>We're sorry, but something went wrong.</h1>
|
|
23
|
+
<p>We've been notified about this issue and we'll take a look at it shortly.</p>
|
|
24
|
+
</div>
|
|
25
|
+
</body>
|
|
26
|
+
</html>
|
|
File without changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
|
3
|
+
|
|
4
|
+
ENV_PATH = File.expand_path('../../config/environment', __FILE__)
|
|
5
|
+
BOOT_PATH = File.expand_path('../../config/boot', __FILE__)
|
|
6
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
|
7
|
+
ROOT_PATH = File.expand_path('../..', __FILE__)
|
|
8
|
+
|
|
9
|
+
require BOOT_PATH
|
|
10
|
+
require 'rails/commands'
|
data/test/routes_test.rb
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class DefaultRoutingTest < ActionController::TestCase
|
|
4
|
+
test 'map new user session' do
|
|
5
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'new'}, {:path => 'users/sign_in', :method => :get})
|
|
6
|
+
assert_named_route "/users/sign_in", :new_user_session_path
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
test 'map create user session' do
|
|
10
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'create'}, {:path => 'users/sign_in', :method => :post})
|
|
11
|
+
assert_named_route "/users/sign_in", :user_session_path
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
test 'map destroy user session' do
|
|
15
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'destroy'}, {:path => 'users/sign_out', :method => :get})
|
|
16
|
+
assert_named_route "/users/sign_out", :destroy_user_session_path
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
test 'map new user confirmation' do
|
|
20
|
+
assert_recognizes({:controller => 'devise/confirmations', :action => 'new'}, 'users/confirmation/new')
|
|
21
|
+
assert_named_route "/users/confirmation/new", :new_user_confirmation_path
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
test 'map create user confirmation' do
|
|
25
|
+
assert_recognizes({:controller => 'devise/confirmations', :action => 'create'}, {:path => 'users/confirmation', :method => :post})
|
|
26
|
+
assert_named_route "/users/confirmation", :user_confirmation_path
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
test 'map show user confirmation' do
|
|
30
|
+
assert_recognizes({:controller => 'devise/confirmations', :action => 'show'}, {:path => 'users/confirmation', :method => :get})
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
test 'map new user password' do
|
|
34
|
+
assert_recognizes({:controller => 'devise/passwords', :action => 'new'}, 'users/password/new')
|
|
35
|
+
assert_named_route "/users/password/new", :new_user_password_path
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
test 'map create user password' do
|
|
39
|
+
assert_recognizes({:controller => 'devise/passwords', :action => 'create'}, {:path => 'users/password', :method => :post})
|
|
40
|
+
assert_named_route "/users/password", :user_password_path
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
test 'map edit user password' do
|
|
44
|
+
assert_recognizes({:controller => 'devise/passwords', :action => 'edit'}, 'users/password/edit')
|
|
45
|
+
assert_named_route "/users/password/edit", :edit_user_password_path
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
test 'map update user password' do
|
|
49
|
+
assert_recognizes({:controller => 'devise/passwords', :action => 'update'}, {:path => 'users/password', :method => :put})
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
test 'map new user unlock' do
|
|
53
|
+
assert_recognizes({:controller => 'devise/unlocks', :action => 'new'}, 'users/unlock/new')
|
|
54
|
+
assert_named_route "/users/unlock/new", :new_user_unlock_path
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
test 'map create user unlock' do
|
|
58
|
+
assert_recognizes({:controller => 'devise/unlocks', :action => 'create'}, {:path => 'users/unlock', :method => :post})
|
|
59
|
+
assert_named_route "/users/unlock", :user_unlock_path
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
test 'map show user unlock' do
|
|
63
|
+
assert_recognizes({:controller => 'devise/unlocks', :action => 'show'}, {:path => 'users/unlock', :method => :get})
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
test 'map new user registration' do
|
|
67
|
+
assert_recognizes({:controller => 'devise/registrations', :action => 'new'}, 'users/sign_up')
|
|
68
|
+
assert_named_route "/users/sign_up", :new_user_registration_path
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
test 'map create user registration' do
|
|
72
|
+
assert_recognizes({:controller => 'devise/registrations', :action => 'create'}, {:path => 'users', :method => :post})
|
|
73
|
+
assert_named_route "/users", :user_registration_path
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
test 'map edit user registration' do
|
|
77
|
+
assert_recognizes({:controller => 'devise/registrations', :action => 'edit'}, {:path => 'users/edit', :method => :get})
|
|
78
|
+
assert_named_route "/users/edit", :edit_user_registration_path
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
test 'map update user registration' do
|
|
82
|
+
assert_recognizes({:controller => 'devise/registrations', :action => 'update'}, {:path => 'users', :method => :put})
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
test 'map destroy user registration' do
|
|
86
|
+
assert_recognizes({:controller => 'devise/registrations', :action => 'destroy'}, {:path => 'users', :method => :delete})
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
test 'map cancel user registration' do
|
|
90
|
+
assert_recognizes({:controller => 'devise/registrations', :action => 'cancel'}, {:path => 'users/cancel', :method => :get})
|
|
91
|
+
assert_named_route "/users/cancel", :cancel_user_registration_path
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
test 'map omniauth callbacks' do
|
|
95
|
+
assert_recognizes({:controller => 'users/omniauth_callbacks', :action => 'facebook'}, {:path => 'users/auth/facebook/callback', :method => :get})
|
|
96
|
+
assert_recognizes({:controller => 'users/omniauth_callbacks', :action => 'facebook'}, {:path => 'users/auth/facebook/callback', :method => :post})
|
|
97
|
+
assert_named_route "/users/auth/facebook/callback", :user_omniauth_callback_path, :facebook
|
|
98
|
+
|
|
99
|
+
assert_raise ActionController::RoutingError do
|
|
100
|
+
assert_recognizes({:controller => 'ysers/omniauth_callbacks', :action => 'twitter'}, {:path => 'users/auth/twitter/callback', :method => :get})
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
protected
|
|
105
|
+
|
|
106
|
+
def assert_named_route(result, *args)
|
|
107
|
+
assert_equal result, @routes.url_helpers.send(*args)
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
class CustomizedRoutingTest < ActionController::TestCase
|
|
112
|
+
test 'map admin with :path option' do
|
|
113
|
+
assert_recognizes({:controller => 'devise/registrations', :action => 'new'}, {:path => 'admin_area/sign_up', :method => :get})
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
test 'map admin with :controllers option' do
|
|
117
|
+
assert_recognizes({:controller => 'admins/sessions', :action => 'new'}, {:path => 'admin_area/sign_in', :method => :get})
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
test 'does not map admin password' do
|
|
121
|
+
assert_raise ActionController::RoutingError do
|
|
122
|
+
assert_recognizes({:controller => 'devise/passwords', :action => 'new'}, 'admin_area/password/new')
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
test 'map account with custom path name for session sign in' do
|
|
127
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'new', :locale => 'en'}, '/en/accounts/login')
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
test 'map account with custom path name for session sign out' do
|
|
131
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'destroy', :locale => 'en'}, '/en/accounts/logout')
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
test 'map account with custom path name for password' do
|
|
135
|
+
assert_recognizes({:controller => 'devise/passwords', :action => 'new', :locale => 'en'}, '/en/accounts/secret/new')
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
test 'map account with custom path name for registration' do
|
|
139
|
+
assert_recognizes({:controller => 'devise/registrations', :action => 'new', :locale => 'en'}, '/en/accounts/management/register')
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
test 'map account with custom path name for cancel registration' do
|
|
143
|
+
assert_recognizes({:controller => 'devise/registrations', :action => 'cancel', :locale => 'en'}, '/en/accounts/management/giveup')
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
test 'map deletes with :sign_out_via option' do
|
|
147
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'destroy'}, {:path => '/sign_out_via/deletes/sign_out', :method => :delete})
|
|
148
|
+
assert_raise ActionController::RoutingError do
|
|
149
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'destroy'}, {:path => '/sign_out_via/deletes/sign_out', :method => :get})
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
test 'map posts with :sign_out_via option' do
|
|
154
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'destroy'}, {:path => '/sign_out_via/posts/sign_out', :method => :post})
|
|
155
|
+
assert_raise ActionController::RoutingError do
|
|
156
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'destroy'}, {:path => '/sign_out_via/posts/sign_out', :method => :get})
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
test 'map delete_or_posts with :sign_out_via option' do
|
|
161
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'destroy'}, {:path => '/sign_out_via/delete_or_posts/sign_out', :method => :post})
|
|
162
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'destroy'}, {:path => '/sign_out_via/delete_or_posts/sign_out', :method => :delete})
|
|
163
|
+
assert_raise ActionController::RoutingError do
|
|
164
|
+
assert_recognizes({:controller => 'devise/sessions', :action => 'destroy'}, {:path => '/sign_out_via/delete_or_posts/sign_out', :method => :get})
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
class ScopedRoutingTest < ActionController::TestCase
|
|
170
|
+
test 'map publisher account' do
|
|
171
|
+
assert_recognizes({:controller => 'publisher/registrations', :action => 'new'}, {:path => '/publisher/accounts/sign_up', :method => :get})
|
|
172
|
+
assert_equal '/publisher/accounts/sign_up', @routes.url_helpers.new_publisher_account_registration_path
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
test 'map publisher account merges path names' do
|
|
176
|
+
assert_recognizes({:controller => 'publisher/sessions', :action => 'new'}, {:path => '/publisher/accounts/get_in', :method => :get})
|
|
177
|
+
assert_equal '/publisher/accounts/get_in', @routes.url_helpers.new_publisher_account_session_path
|
|
178
|
+
end
|
|
179
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'active_support/test_case'
|
|
2
|
+
|
|
3
|
+
class ActiveSupport::TestCase
|
|
4
|
+
def assert_not(assertion)
|
|
5
|
+
assert !assertion
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def assert_blank(assertion)
|
|
9
|
+
assert assertion.blank?
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def assert_not_blank(assertion)
|
|
13
|
+
assert !assertion.blank?
|
|
14
|
+
end
|
|
15
|
+
alias :assert_present :assert_not_blank
|
|
16
|
+
|
|
17
|
+
def assert_email_sent(&block)
|
|
18
|
+
assert_difference('ActionMailer::Base.deliveries.size') { yield }
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def assert_email_not_sent(&block)
|
|
22
|
+
assert_no_difference('ActionMailer::Base.deliveries.size') { yield }
|
|
23
|
+
end
|
|
24
|
+
end
|