af-devise 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (207) hide show
  1. data/.gitignore +10 -0
  2. data/.travis.yml +15 -0
  3. data/CHANGELOG.rdoc +885 -0
  4. data/CONTRIBUTING.md +14 -0
  5. data/Gemfile +29 -0
  6. data/Gemfile.lock +155 -0
  7. data/MIT-LICENSE +20 -0
  8. data/README.md +394 -0
  9. data/Rakefile +34 -0
  10. data/app/controllers/devise/confirmations_controller.rb +43 -0
  11. data/app/controllers/devise/omniauth_callbacks_controller.rb +30 -0
  12. data/app/controllers/devise/passwords_controller.rb +65 -0
  13. data/app/controllers/devise/registrations_controller.rb +119 -0
  14. data/app/controllers/devise/sessions_controller.rb +50 -0
  15. data/app/controllers/devise/unlocks_controller.rb +44 -0
  16. data/app/controllers/devise_controller.rb +184 -0
  17. data/app/helpers/devise_helper.rb +25 -0
  18. data/app/mailers/devise/mailer.rb +15 -0
  19. data/app/views/devise/_links.erb +3 -0
  20. data/app/views/devise/confirmations/new.html.erb +12 -0
  21. data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
  22. data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  23. data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  24. data/app/views/devise/passwords/edit.html.erb +16 -0
  25. data/app/views/devise/passwords/new.html.erb +12 -0
  26. data/app/views/devise/registrations/edit.html.erb +25 -0
  27. data/app/views/devise/registrations/new.html.erb +18 -0
  28. data/app/views/devise/sessions/new.html.erb +17 -0
  29. data/app/views/devise/shared/_links.erb +25 -0
  30. data/app/views/devise/unlocks/new.html.erb +12 -0
  31. data/config/locales/en.yml +59 -0
  32. data/devise.gemspec +25 -0
  33. data/gemfiles/Gemfile.rails-3.1.x +35 -0
  34. data/gemfiles/Gemfile.rails-3.1.x.lock +167 -0
  35. data/lib/devise.rb +444 -0
  36. data/lib/devise/controllers/helpers.rb +285 -0
  37. data/lib/devise/controllers/rememberable.rb +52 -0
  38. data/lib/devise/controllers/scoped_views.rb +17 -0
  39. data/lib/devise/controllers/url_helpers.rb +67 -0
  40. data/lib/devise/delegator.rb +16 -0
  41. data/lib/devise/failure_app.rb +187 -0
  42. data/lib/devise/hooks/activatable.rb +11 -0
  43. data/lib/devise/hooks/forgetable.rb +9 -0
  44. data/lib/devise/hooks/lockable.rb +7 -0
  45. data/lib/devise/hooks/rememberable.rb +6 -0
  46. data/lib/devise/hooks/timeoutable.rb +25 -0
  47. data/lib/devise/hooks/trackable.rb +9 -0
  48. data/lib/devise/mailers/helpers.rb +91 -0
  49. data/lib/devise/mapping.rb +172 -0
  50. data/lib/devise/models.rb +128 -0
  51. data/lib/devise/models/authenticatable.rb +268 -0
  52. data/lib/devise/models/confirmable.rb +270 -0
  53. data/lib/devise/models/database_authenticatable.rb +127 -0
  54. data/lib/devise/models/lockable.rb +193 -0
  55. data/lib/devise/models/omniauthable.rb +27 -0
  56. data/lib/devise/models/recoverable.rb +140 -0
  57. data/lib/devise/models/registerable.rb +25 -0
  58. data/lib/devise/models/rememberable.rb +125 -0
  59. data/lib/devise/models/timeoutable.rb +49 -0
  60. data/lib/devise/models/token_authenticatable.rb +89 -0
  61. data/lib/devise/models/trackable.rb +35 -0
  62. data/lib/devise/models/validatable.rb +66 -0
  63. data/lib/devise/modules.rb +29 -0
  64. data/lib/devise/omniauth.rb +28 -0
  65. data/lib/devise/omniauth/config.rb +45 -0
  66. data/lib/devise/omniauth/url_helpers.rb +18 -0
  67. data/lib/devise/orm/active_record.rb +3 -0
  68. data/lib/devise/orm/mongoid.rb +3 -0
  69. data/lib/devise/param_filter.rb +41 -0
  70. data/lib/devise/rails.rb +54 -0
  71. data/lib/devise/rails/routes.rb +446 -0
  72. data/lib/devise/rails/warden_compat.rb +43 -0
  73. data/lib/devise/strategies/authenticatable.rb +176 -0
  74. data/lib/devise/strategies/base.rb +20 -0
  75. data/lib/devise/strategies/database_authenticatable.rb +20 -0
  76. data/lib/devise/strategies/rememberable.rb +55 -0
  77. data/lib/devise/strategies/token_authenticatable.rb +56 -0
  78. data/lib/devise/test_helpers.rb +131 -0
  79. data/lib/devise/time_inflector.rb +14 -0
  80. data/lib/devise/version.rb +3 -0
  81. data/lib/generators/active_record/devise_generator.rb +79 -0
  82. data/lib/generators/active_record/templates/migration.rb +19 -0
  83. data/lib/generators/active_record/templates/migration_existing.rb +26 -0
  84. data/lib/generators/devise/devise_generator.rb +24 -0
  85. data/lib/generators/devise/install_generator.rb +24 -0
  86. data/lib/generators/devise/orm_helpers.rb +32 -0
  87. data/lib/generators/devise/views_generator.rb +116 -0
  88. data/lib/generators/mongoid/devise_generator.rb +57 -0
  89. data/lib/generators/templates/README +35 -0
  90. data/lib/generators/templates/devise.rb +240 -0
  91. data/lib/generators/templates/markerb/confirmation_instructions.markerb +5 -0
  92. data/lib/generators/templates/markerb/reset_password_instructions.markerb +8 -0
  93. data/lib/generators/templates/markerb/unlock_instructions.markerb +7 -0
  94. data/lib/generators/templates/simple_form_for/confirmations/new.html.erb +15 -0
  95. data/lib/generators/templates/simple_form_for/passwords/edit.html.erb +19 -0
  96. data/lib/generators/templates/simple_form_for/passwords/new.html.erb +15 -0
  97. data/lib/generators/templates/simple_form_for/registrations/edit.html.erb +22 -0
  98. data/lib/generators/templates/simple_form_for/registrations/new.html.erb +17 -0
  99. data/lib/generators/templates/simple_form_for/sessions/new.html.erb +15 -0
  100. data/lib/generators/templates/simple_form_for/unlocks/new.html.erb +15 -0
  101. data/test/controllers/custom_strategy_test.rb +62 -0
  102. data/test/controllers/helpers_test.rb +253 -0
  103. data/test/controllers/internal_helpers_test.rb +110 -0
  104. data/test/controllers/sessions_controller_test.rb +85 -0
  105. data/test/controllers/url_helpers_test.rb +59 -0
  106. data/test/delegator_test.rb +19 -0
  107. data/test/devise_test.rb +72 -0
  108. data/test/failure_app_test.rb +221 -0
  109. data/test/generators/active_record_generator_test.rb +75 -0
  110. data/test/generators/devise_generator_test.rb +39 -0
  111. data/test/generators/install_generator_test.rb +13 -0
  112. data/test/generators/mongoid_generator_test.rb +23 -0
  113. data/test/generators/views_generator_test.rb +52 -0
  114. data/test/helpers/devise_helper_test.rb +51 -0
  115. data/test/integration/authenticatable_test.rb +633 -0
  116. data/test/integration/confirmable_test.rb +298 -0
  117. data/test/integration/database_authenticatable_test.rb +82 -0
  118. data/test/integration/http_authenticatable_test.rb +97 -0
  119. data/test/integration/lockable_test.rb +242 -0
  120. data/test/integration/omniauthable_test.rb +133 -0
  121. data/test/integration/recoverable_test.rb +334 -0
  122. data/test/integration/registerable_test.rb +345 -0
  123. data/test/integration/rememberable_test.rb +158 -0
  124. data/test/integration/timeoutable_test.rb +140 -0
  125. data/test/integration/token_authenticatable_test.rb +161 -0
  126. data/test/integration/trackable_test.rb +92 -0
  127. data/test/mailers/confirmation_instructions_test.rb +102 -0
  128. data/test/mailers/reset_password_instructions_test.rb +83 -0
  129. data/test/mailers/unlock_instructions_test.rb +77 -0
  130. data/test/mapping_test.rb +127 -0
  131. data/test/models/authenticatable_test.rb +7 -0
  132. data/test/models/confirmable_test.rb +391 -0
  133. data/test/models/database_authenticatable_test.rb +196 -0
  134. data/test/models/lockable_test.rb +273 -0
  135. data/test/models/omniauthable_test.rb +7 -0
  136. data/test/models/recoverable_test.rb +205 -0
  137. data/test/models/registerable_test.rb +7 -0
  138. data/test/models/rememberable_test.rb +174 -0
  139. data/test/models/serializable_test.rb +49 -0
  140. data/test/models/timeoutable_test.rb +46 -0
  141. data/test/models/token_authenticatable_test.rb +55 -0
  142. data/test/models/trackable_test.rb +13 -0
  143. data/test/models/validatable_test.rb +117 -0
  144. data/test/models_test.rb +179 -0
  145. data/test/omniauth/config_test.rb +57 -0
  146. data/test/omniauth/url_helpers_test.rb +51 -0
  147. data/test/orm/active_record.rb +9 -0
  148. data/test/orm/mongoid.rb +13 -0
  149. data/test/rails_app/Rakefile +10 -0
  150. data/test/rails_app/app/active_record/admin.rb +6 -0
  151. data/test/rails_app/app/active_record/shim.rb +2 -0
  152. data/test/rails_app/app/active_record/user.rb +6 -0
  153. data/test/rails_app/app/controllers/admins/sessions_controller.rb +6 -0
  154. data/test/rails_app/app/controllers/admins_controller.rb +11 -0
  155. data/test/rails_app/app/controllers/application_controller.rb +8 -0
  156. data/test/rails_app/app/controllers/home_controller.rb +25 -0
  157. data/test/rails_app/app/controllers/publisher/registrations_controller.rb +2 -0
  158. data/test/rails_app/app/controllers/publisher/sessions_controller.rb +2 -0
  159. data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +14 -0
  160. data/test/rails_app/app/controllers/users_controller.rb +23 -0
  161. data/test/rails_app/app/helpers/application_helper.rb +3 -0
  162. data/test/rails_app/app/mailers/users/mailer.rb +8 -0
  163. data/test/rails_app/app/mongoid/admin.rb +29 -0
  164. data/test/rails_app/app/mongoid/shim.rb +24 -0
  165. data/test/rails_app/app/mongoid/user.rb +42 -0
  166. data/test/rails_app/app/views/admins/index.html.erb +1 -0
  167. data/test/rails_app/app/views/admins/sessions/new.html.erb +2 -0
  168. data/test/rails_app/app/views/home/admin_dashboard.html.erb +1 -0
  169. data/test/rails_app/app/views/home/index.html.erb +1 -0
  170. data/test/rails_app/app/views/home/join.html.erb +1 -0
  171. data/test/rails_app/app/views/home/private.html.erb +1 -0
  172. data/test/rails_app/app/views/home/user_dashboard.html.erb +1 -0
  173. data/test/rails_app/app/views/layouts/application.html.erb +24 -0
  174. data/test/rails_app/app/views/users/index.html.erb +1 -0
  175. data/test/rails_app/app/views/users/mailer/confirmation_instructions.erb +1 -0
  176. data/test/rails_app/app/views/users/sessions/new.html.erb +1 -0
  177. data/test/rails_app/config.ru +4 -0
  178. data/test/rails_app/config/application.rb +41 -0
  179. data/test/rails_app/config/boot.rb +8 -0
  180. data/test/rails_app/config/database.yml +18 -0
  181. data/test/rails_app/config/environment.rb +5 -0
  182. data/test/rails_app/config/environments/development.rb +18 -0
  183. data/test/rails_app/config/environments/production.rb +33 -0
  184. data/test/rails_app/config/environments/test.rb +33 -0
  185. data/test/rails_app/config/initializers/backtrace_silencers.rb +7 -0
  186. data/test/rails_app/config/initializers/devise.rb +178 -0
  187. data/test/rails_app/config/initializers/inflections.rb +2 -0
  188. data/test/rails_app/config/initializers/secret_token.rb +2 -0
  189. data/test/rails_app/config/routes.rb +100 -0
  190. data/test/rails_app/db/migrate/20100401102949_create_tables.rb +74 -0
  191. data/test/rails_app/db/schema.rb +52 -0
  192. data/test/rails_app/lib/shared_admin.rb +14 -0
  193. data/test/rails_app/lib/shared_user.rb +26 -0
  194. data/test/rails_app/public/404.html +26 -0
  195. data/test/rails_app/public/422.html +26 -0
  196. data/test/rails_app/public/500.html +26 -0
  197. data/test/rails_app/public/favicon.ico +0 -0
  198. data/test/rails_app/script/rails +10 -0
  199. data/test/routes_test.rb +248 -0
  200. data/test/support/assertions.rb +40 -0
  201. data/test/support/helpers.rb +91 -0
  202. data/test/support/integration.rb +92 -0
  203. data/test/support/locale/en.yml +4 -0
  204. data/test/support/webrat/integrations/rails.rb +24 -0
  205. data/test/test_helper.rb +27 -0
  206. data/test/test_helpers_test.rb +151 -0
  207. metadata +421 -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,178 @@
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 8..128.
89
+ # config.password_length = 8..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
+ # Setup a pepper to generate the encrypted password.
133
+ config.pepper = "d142367154e5beacca404b1a6a4f8bc52c6fdcfa3ccc3cf8eb49f3458a688ee6ac3b9fae488432a3bfca863b8a90008368a9f3a3dfbe5a962e64b6ab8f3a3a1a"
134
+
135
+ # ==> Configuration for :token_authenticatable
136
+ # Defines name of the authentication token params key
137
+ # config.token_authentication_key = :auth_token
138
+
139
+ # ==> Scopes configuration
140
+ # Turn scoped views on. Before rendering "sessions/new", it will first check for
141
+ # "users/sessions/new". It's turned off by default because it's slower if you
142
+ # are using only default views.
143
+ # config.scoped_views = false
144
+
145
+ # Configure the default scope given to Warden. By default it's the first
146
+ # devise role declared in your routes (usually :user).
147
+ # config.default_scope = :user
148
+
149
+ # Configure sign_out behavior.
150
+ # Sign_out action can be scoped (i.e. /users/sign_out affects only :user scope).
151
+ # The default is true, which means any logout action will sign out all active scopes.
152
+ # config.sign_out_all_scopes = true
153
+
154
+ # ==> Navigation configuration
155
+ # Lists the formats that should be treated as navigational. Formats like
156
+ # :html, should redirect to the sign in page when the user does not have
157
+ # access, but formats like :xml or :json, should return 401.
158
+ # If you have any extra navigational formats, like :iphone or :mobile, you
159
+ # should add them to the navigational formats lists. Default is [:html]
160
+ # config.navigational_formats = [:html, :iphone]
161
+
162
+ # The default HTTP method used to sign out a resource. Default is :get.
163
+ # config.sign_out_via = :get
164
+
165
+ # ==> OmniAuth
166
+ config.omniauth :facebook, 'APP_ID', 'APP_SECRET', :scope => 'email,offline_access'
167
+ config.omniauth :openid
168
+ config.omniauth :openid, :name => 'google', :identifier => 'https://www.google.com/accounts/o8/id'
169
+
170
+ # ==> Warden configuration
171
+ # If you want to use other strategies, that are not supported by Devise, or
172
+ # change the failure app, you can configure them inside the config.warden block.
173
+ #
174
+ # config.warden do |manager|
175
+ # manager.failure_app = AnotherApp
176
+ # manager.default_strategies(:scope => :user).unshift :some_external_strategy
177
+ # end
178
+ 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,100 @@
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] do
13
+ get :expire, :on => :member
14
+ end
15
+
16
+ # Users scope
17
+ devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }
18
+
19
+ as :user do
20
+ match "/as/sign_in", :to => "devise/sessions#new"
21
+ end
22
+
23
+ match "/sign_in", :to => "devise/sessions#new"
24
+
25
+ # Admin scope
26
+ devise_for :admin, :path => "admin_area", :controllers => { :sessions => :"admins/sessions" }, :skip => :passwords
27
+
28
+ match "/admin_area/home", :to => "admins#index", :as => :admin_root
29
+ match "/anywhere", :to => "foo#bar", :as => :new_admin_password
30
+
31
+ authenticate(:admin) do
32
+ match "/private", :to => "home#private", :as => :private
33
+ end
34
+
35
+ authenticate(:admin, lambda { |admin| admin.active? }) do
36
+ match "/private/active", :to => "home#private", :as => :private_active
37
+ end
38
+
39
+ authenticated :admin do
40
+ match "/dashboard", :to => "home#admin_dashboard"
41
+ end
42
+
43
+ authenticated :admin, lambda { |admin| admin.active? } do
44
+ match "/dashboard/active", :to => "home#admin_dashboard"
45
+ end
46
+
47
+ authenticated do
48
+ match "/dashboard", :to => "home#user_dashboard"
49
+ end
50
+
51
+ unauthenticated do
52
+ match "/join", :to => "home#join"
53
+ end
54
+
55
+ # Routes for constraints testing
56
+ devise_for :headquarters_admin, :class_name => "Admin", :path => "headquarters", :constraints => {:host => /192\.168\.1\.\d\d\d/}
57
+
58
+ constraints(:host => /192\.168\.1\.\d\d\d/) do
59
+ devise_for :homebase_admin, :class_name => "Admin", :path => "homebase"
60
+ end
61
+
62
+ devise_for :skip_admin, :class_name => "Admin", :skip => :all
63
+
64
+ # Routes for format=false testing
65
+ devise_for :htmlonly_admin, :class_name => "Admin", :skip => [:confirmations, :unlocks], :path => "htmlonly_admin", :format => false, :skip_helpers => [:confirmations, :unlocks]
66
+ devise_for :htmlonly_users, :class_name => "User", :only => [:confirmations, :unlocks], :path => "htmlonly_users", :format => false, :skip_helpers => true
67
+
68
+ # Other routes for routing_test.rb
69
+ devise_for :reader, :class_name => "User", :only => :passwords
70
+
71
+ scope :host => "sub.example.com" do
72
+ devise_for :sub_admin, :class_name => "Admin"
73
+ end
74
+
75
+ namespace :publisher, :path_names => { :sign_in => "i_dont_care", :sign_out => "get_out" } do
76
+ devise_for :accounts, :class_name => "Admin", :path_names => { :sign_in => "get_in" }
77
+ end
78
+
79
+ scope ":locale", :module => :invalid do
80
+ devise_for :accounts, :singular => "manager", :class_name => "Admin",
81
+ :path_names => {
82
+ :sign_in => "login", :sign_out => "logout",
83
+ :password => "secret", :confirmation => "verification",
84
+ :unlock => "unblock", :sign_up => "register",
85
+ :registration => "management", :cancel => "giveup"
86
+ }, :failure_app => lambda { |env| [404, {"Content-Type" => "text/plain"}, ["Oops, not found"]] }, :module => :devise
87
+ end
88
+
89
+ namespace :sign_out_via, :module => "devise" do
90
+ devise_for :deletes, :sign_out_via => :delete, :class_name => "Admin"
91
+ devise_for :posts, :sign_out_via => :post, :class_name => "Admin"
92
+ devise_for :delete_or_posts, :sign_out_via => [:delete, :post], :class_name => "Admin"
93
+ end
94
+
95
+ match "/set", :to => "home#set"
96
+ match "/unauthenticated", :to => "home#unauthenticated"
97
+ match "/custom_strategy/new"
98
+
99
+ root :to => "home#index"
100
+ end
@@ -0,0 +1,74 @@
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
+ ## Confirmable
26
+ t.string :confirmation_token
27
+ t.datetime :confirmed_at
28
+ t.datetime :confirmation_sent_at
29
+ # t.string :unconfirmed_email # Only if using reconfirmable
30
+
31
+ ## Lockable
32
+ t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
33
+ t.string :unlock_token # Only if unlock strategy is :email or :both
34
+ t.datetime :locked_at
35
+
36
+ ## Token authenticatable
37
+ t.string :authentication_token
38
+
39
+ t.timestamps
40
+ end
41
+
42
+ create_table :admins do |t|
43
+ ## Database authenticatable
44
+ t.string :email, :null => true
45
+ t.string :encrypted_password, :null => true
46
+
47
+ ## Recoverable
48
+ t.string :reset_password_token
49
+ t.datetime :reset_password_sent_at
50
+
51
+ ## Rememberable
52
+ t.datetime :remember_created_at
53
+
54
+ ## Confirmable
55
+ t.string :confirmation_token
56
+ t.datetime :confirmed_at
57
+ t.datetime :confirmation_sent_at
58
+ t.string :unconfirmed_email # Only if using reconfirmable
59
+
60
+ ## Lockable
61
+ t.datetime :locked_at
62
+
63
+ ## Attribute for testing route blocks
64
+ t.boolean :active, :default => false
65
+
66
+ t.timestamps
67
+ end
68
+ end
69
+
70
+ def self.down
71
+ drop_table :users
72
+ drop_table :admins
73
+ end
74
+ 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