double_auth_engine 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/.rvmrc +1 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +136 -0
- data/MIT-LICENSE +20 -0
- data/README.md +59 -0
- data/Rakefile +25 -0
- data/app/controllers/password_resets_controller.rb +3 -0
- data/app/controllers/user_sessions_controller.rb +3 -0
- data/app/controllers/users_controller.rb +3 -0
- data/app/mailers/notifier.rb +8 -0
- data/app/models/assignment.rb +3 -0
- data/app/models/role.rb +3 -0
- data/app/models/user.rb +3 -0
- data/app/models/user_session.rb +3 -0
- data/app/views/notifier/password_reset_instructions.text.erb +8 -0
- data/app/views/password_resets/edit.html.erb +5 -0
- data/app/views/password_resets/new.html.erb +5 -0
- data/app/views/user_sessions/new.html.erb +17 -0
- data/app/views/users/edit.html.erb +0 -0
- data/app/views/users/index.html.erb +0 -0
- data/app/views/users/new.html.erb +20 -0
- data/app/views/users/show.html.erb +2 -0
- data/config/routes.rb +11 -0
- data/double_auth_engine.gemspec +26 -0
- data/lib/double_auth_engine/controllers/application_controller_mixin.rb +42 -0
- data/lib/double_auth_engine/controllers/password_resets_controller_mixin.rb +49 -0
- data/lib/double_auth_engine/controllers/user_sessions_controller_mixin.rb +34 -0
- data/lib/double_auth_engine/controllers/users_controller_mixin.rb +63 -0
- data/lib/double_auth_engine/generators/double_auth_engine/install_generator.rb +48 -0
- data/lib/double_auth_engine/generators/double_auth_engine/templates/assignment_migration.rb +13 -0
- data/lib/double_auth_engine/generators/double_auth_engine/templates/authorization_rules.rb +19 -0
- data/lib/double_auth_engine/generators/double_auth_engine/templates/role_migration.rb +12 -0
- data/lib/double_auth_engine/generators/double_auth_engine/templates/setup_mail_initializer.rb +7 -0
- data/lib/double_auth_engine/generators/double_auth_engine/templates/user_migration.rb +28 -0
- data/lib/double_auth_engine/models/assignment_mixin.rb +10 -0
- data/lib/double_auth_engine/models/role_mixin.rb +10 -0
- data/lib/double_auth_engine/models/user_mixin.rb +38 -0
- data/lib/double_auth_engine/models/user_session_mixin.rb +15 -0
- data/lib/double_auth_engine/tasks/migrate_seed.rake +9 -0
- data/lib/double_auth_engine/version.rb +3 -0
- data/lib/double_auth_engine.rb +15 -0
- data/lib/engine.rb +23 -0
- data/spec/double_auth_engine_spec.rb +7 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +4 -0
- data/spec/dummy/app/controllers/dashboard_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/dashboard/index.html.erb +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config/application.rb +48 -0
- data/spec/dummy/config/authorization_rules.rb +20 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +22 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +29 -0
- data/spec/dummy/config/environments/production.rb +52 -0
- data/spec/dummy/config/environments/test.rb +35 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/setup_mail.rb +9 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/migrate/20110408030355_create_users.rb +28 -0
- data/spec/dummy/db/migrate/20110408030356_create_roles.rb +12 -0
- data/spec/dummy/db/migrate/20110408030357_create_assignments.rb +13 -0
- data/spec/dummy/db/schema.rb +51 -0
- data/spec/dummy/db/seeds.rb +3 -0
- data/spec/dummy/lib/development_mail_interceptor.rb +6 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/javascripts/application.js +2 -0
- data/spec/dummy/public/javascripts/controls.js +965 -0
- data/spec/dummy/public/javascripts/dragdrop.js +974 -0
- data/spec/dummy/public/javascripts/effects.js +1123 -0
- data/spec/dummy/public/javascripts/prototype.js +6001 -0
- data/spec/dummy/public/javascripts/rails.js +175 -0
- data/spec/dummy/public/stylesheets/.gitkeep +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/dummy/spec/authorizations/user_spec.rb +104 -0
- data/spec/dummy/spec/controllers/user_sessions_controller_spec.rb +48 -0
- data/spec/dummy/spec/controllers/users_controller_spec.rb +125 -0
- data/spec/dummy/spec/models/user_spec.rb +65 -0
- data/spec/integration/navigation_spec.rb +9 -0
- data/spec/spec_helper.rb +42 -0
- data/spec/support/user_authentication.rb +14 -0
- data/spec/support/user_authorization.rb +17 -0
- metadata +218 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
authorization do
|
2
|
+
role :guest do
|
3
|
+
has_permission_on :users, :to => [:modify, :destroy] do
|
4
|
+
if_attribute :id => is { user.id }
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
role :admin do
|
9
|
+
includes :guest
|
10
|
+
has_permission_on :users, :to => [:modify, :destroy]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
privileges do
|
15
|
+
privilege :add, :includes => [:new, :create]
|
16
|
+
privilege :modify, :includes => [:edit, :update]
|
17
|
+
privilege :read, :includes => [:index, :show]
|
18
|
+
privilege :write, :includes => [:add, :modify]
|
19
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class CreateUsers < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :users do |t|
|
4
|
+
t.string :email, :null => false
|
5
|
+
t.string :name, :limit => 100, :null => false
|
6
|
+
t.string :location, :limit => 150
|
7
|
+
t.string :crypted_password, :null => false
|
8
|
+
t.string :password_salt, :null => false
|
9
|
+
t.string :persistence_token, :null => false
|
10
|
+
t.string :single_access_token, :null => false
|
11
|
+
t.string :perishable_token, :null => false
|
12
|
+
t.integer :login_count, :null => false, :default => 0
|
13
|
+
t.integer :failed_login_count, :null => false, :default => 0
|
14
|
+
t.datetime :last_request_at
|
15
|
+
t.datetime :current_login_at
|
16
|
+
t.datetime :last_login_at
|
17
|
+
t.string :current_login_ip
|
18
|
+
t.string :last_login_ip
|
19
|
+
t.timestamps
|
20
|
+
end
|
21
|
+
add_index :users, :email, :unique => true
|
22
|
+
add_index :users, :perishable_token
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.down
|
26
|
+
drop_table :users
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module DoubleAuthEngine
|
2
|
+
module UserMixin
|
3
|
+
def self.included(base)
|
4
|
+
base.class_eval do
|
5
|
+
acts_as_authentic
|
6
|
+
validates :email, :name, :presence => true
|
7
|
+
has_many :assignments
|
8
|
+
has_many :roles, :through => :assignments
|
9
|
+
end
|
10
|
+
base.send :extend, ClassMethods
|
11
|
+
base.send :include, InstanceMethods
|
12
|
+
end
|
13
|
+
|
14
|
+
module ClassMethods
|
15
|
+
def self.emails(query)
|
16
|
+
(User.all(:select => "DISTINCT(email)",
|
17
|
+
:conditions => ["email LIKE ?", "%#{query}%"])).map(& :email).compact
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
module InstanceMethods
|
22
|
+
def email=(value)
|
23
|
+
write_attribute :email, (value ? value.downcase : nil)
|
24
|
+
end
|
25
|
+
|
26
|
+
def deliver_password_reset_instructions!
|
27
|
+
reset_perishable_token!
|
28
|
+
Notifier.password_reset_instructions(self).deliver
|
29
|
+
end
|
30
|
+
|
31
|
+
def role_symbols
|
32
|
+
roles.map do |role|
|
33
|
+
role.name.underscore.to_sym
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module DoubleAuthEngine
|
2
|
+
module UserSessionMixin
|
3
|
+
def self.included(base)
|
4
|
+
base.class_eval do
|
5
|
+
include ActiveModel::Conversion
|
6
|
+
end
|
7
|
+
base.send :include, InstanceMethods
|
8
|
+
end
|
9
|
+
|
10
|
+
module InstanceMethods
|
11
|
+
def persisted?;
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module DoubleAuthEngine
|
2
|
+
require "engine" if defined?(Rails) && Rails::VERSION::MAJOR == 3
|
3
|
+
require "authlogic"
|
4
|
+
require "declarative_authorization"
|
5
|
+
require File.join(File.dirname(__FILE__), "double_auth_engine", "models", "user_mixin")
|
6
|
+
require File.join(File.dirname(__FILE__), "double_auth_engine", "models", "user_session_mixin")
|
7
|
+
require File.join(File.dirname(__FILE__), "double_auth_engine", "models", "assignment_mixin")
|
8
|
+
require File.join(File.dirname(__FILE__), "double_auth_engine", "models", "role_mixin")
|
9
|
+
require File.join(File.dirname(__FILE__), "double_auth_engine", "controllers", "application_controller_mixin")
|
10
|
+
require File.join(File.dirname(__FILE__), "double_auth_engine", "controllers", "user_sessions_controller_mixin")
|
11
|
+
require File.join(File.dirname(__FILE__), "double_auth_engine", "controllers", "users_controller_mixin")
|
12
|
+
require File.join(File.dirname(__FILE__), "double_auth_engine", "controllers", "password_resets_controller_mixin")
|
13
|
+
require File.join(File.dirname(__FILE__), "double_auth_engine", "generators", "double_auth_engine", "install_generator")
|
14
|
+
require File.join(File.dirname(__FILE__), "double_auth_engine", "version")
|
15
|
+
end
|
data/lib/engine.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rails'
|
2
|
+
|
3
|
+
module DoubleAuthEngine
|
4
|
+
class Engine < Rails::Engine
|
5
|
+
# Config defaults
|
6
|
+
config.mount_at = '/'
|
7
|
+
|
8
|
+
# Load rake tasks
|
9
|
+
rake_tasks do
|
10
|
+
load File.join(File.dirname(__FILE__), 'double_auth_engine/tasks/migrate_seed.rake')
|
11
|
+
end
|
12
|
+
|
13
|
+
# Check the gem config
|
14
|
+
initializer "check config" do |app|
|
15
|
+
# make sure mount_at ends with trailing slash
|
16
|
+
config.mount_at += '/' unless config.mount_at.last == '/'
|
17
|
+
end
|
18
|
+
|
19
|
+
initializer "static assets" do |app|
|
20
|
+
app.middleware.use ::ActionDispatch::Static, "#{root}/public"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/spec/dummy/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
|
+
|
4
|
+
require File.expand_path('../config/application', __FILE__)
|
5
|
+
require 'rake'
|
6
|
+
|
7
|
+
Dummy::Application.load_tasks
|
File without changes
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require "active_model/railtie"
|
4
|
+
require "active_record/railtie"
|
5
|
+
require "action_controller/railtie"
|
6
|
+
require "action_view/railtie"
|
7
|
+
require "action_mailer/railtie"
|
8
|
+
|
9
|
+
Bundler.require
|
10
|
+
require "double_auth_engine"
|
11
|
+
|
12
|
+
module Dummy
|
13
|
+
class Application < Rails::Application
|
14
|
+
# Settings in config/environments/* take precedence over those specified here.
|
15
|
+
# Application configuration should go into files in config/initializers
|
16
|
+
# -- all .rb files in that directory are automatically loaded.
|
17
|
+
|
18
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
19
|
+
config.autoload_paths += %W(#{Rails.root}/lib)
|
20
|
+
|
21
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
22
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
23
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
24
|
+
|
25
|
+
# Activate observers that should always be running.
|
26
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
27
|
+
|
28
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
29
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
30
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
31
|
+
|
32
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
33
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
34
|
+
# config.i18n.default_locale = :de
|
35
|
+
|
36
|
+
# JavaScript files you want as :defaults (application.js is always included).
|
37
|
+
# config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
|
38
|
+
|
39
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
40
|
+
config.encoding = "utf-8"
|
41
|
+
|
42
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
43
|
+
config.filter_parameters += [:password]
|
44
|
+
|
45
|
+
# Mailer configuration
|
46
|
+
config.action_mailer.delivery_method = :sendmail
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
authorization do
|
2
|
+
role :guest do
|
3
|
+
has_permission_on :users, :to => [:add, :read]
|
4
|
+
has_permission_on :users, :to => [:modify, :destroy] do
|
5
|
+
if_attribute :id => is { user.id }
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
role :admin do
|
10
|
+
includes :guest
|
11
|
+
has_permission_on :users, :to => [:modify, :destroy]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
privileges do
|
16
|
+
privilege :add, :includes => [:new, :create]
|
17
|
+
privilege :modify, :includes => [:edit, :update]
|
18
|
+
privilege :read, :includes => [:index, :show]
|
19
|
+
privilege :write, :includes => [:add, :modify]
|
20
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# SQLite version 3.x
|
2
|
+
# gem install sqlite3-ruby (not necessary on OS X Leopard)
|
3
|
+
development:
|
4
|
+
adapter: sqlite3
|
5
|
+
database: db/development.sqlite3
|
6
|
+
pool: 5
|
7
|
+
timeout: 5000
|
8
|
+
|
9
|
+
# Warning: The database defined as "test" will be erased and
|
10
|
+
# re-generated from your development database when you run "rake".
|
11
|
+
# Do not set this db to the same as development or production.
|
12
|
+
test:
|
13
|
+
adapter: sqlite3
|
14
|
+
database: db/test.sqlite3
|
15
|
+
pool: 5
|
16
|
+
timeout: 5000
|
17
|
+
|
18
|
+
production:
|
19
|
+
adapter: sqlite3
|
20
|
+
database: db/production.sqlite3
|
21
|
+
pool: 5
|
22
|
+
timeout: 5000
|
@@ -0,0 +1,29 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the webserver when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Log error messages when you accidentally call methods on nil.
|
10
|
+
config.whiny_nils = true
|
11
|
+
|
12
|
+
# Show full error reports and disable caching
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
config.action_view.debug_rjs = true
|
15
|
+
config.action_controller.perform_caching = false
|
16
|
+
|
17
|
+
# Mailer configuration
|
18
|
+
config.action_mailer.delivery_method = :sendmail
|
19
|
+
config.action_mailer.raise_delivery_errors = false
|
20
|
+
config.action_mailer.perform_deliveries = true
|
21
|
+
config.action_mailer.default_url_options = { :host => "localhost:3000" }
|
22
|
+
|
23
|
+
# Print deprecation notices to the Rails logger
|
24
|
+
config.active_support.deprecation = :log
|
25
|
+
|
26
|
+
# Only use best-standards-support built into browsers
|
27
|
+
config.action_dispatch.best_standards_support = :builtin
|
28
|
+
end
|
29
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# The production environment is meant for finished, "live" apps.
|
5
|
+
# Code is not reloaded between requests
|
6
|
+
config.cache_classes = true
|
7
|
+
|
8
|
+
# Full error reports are disabled and caching is turned on
|
9
|
+
config.consider_all_requests_local = false
|
10
|
+
config.action_controller.perform_caching = true
|
11
|
+
|
12
|
+
# Specifies the header that your server uses for sending files
|
13
|
+
config.action_dispatch.x_sendfile_header = "X-Sendfile"
|
14
|
+
|
15
|
+
# For nginx:
|
16
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
|
17
|
+
|
18
|
+
# If you have no front-end server that supports something like X-Sendfile,
|
19
|
+
# just comment this out and Rails will serve the files
|
20
|
+
|
21
|
+
# See everything in the log (default is :info)
|
22
|
+
# config.log_level = :debug
|
23
|
+
|
24
|
+
# Use a different logger for distributed setups
|
25
|
+
# config.logger = SyslogLogger.new
|
26
|
+
|
27
|
+
# Use a different cache store in production
|
28
|
+
# config.cache_store = :mem_cache_store
|
29
|
+
|
30
|
+
# Disable Rails's static asset server
|
31
|
+
# In production, Apache or nginx will already do this
|
32
|
+
config.serve_static_assets = false
|
33
|
+
|
34
|
+
# Enable serving of images, stylesheets, and javascripts from an asset server
|
35
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
36
|
+
|
37
|
+
# Mailer configuration
|
38
|
+
config.action_mailer.delivery_method = :sendmail
|
39
|
+
config.action_mailer.raise_delivery_errors = true
|
40
|
+
config.action_mailer.perform_deliveries = true
|
41
|
+
config.action_mailer.default_url_options = { :host => "gamedayroster.com" }
|
42
|
+
|
43
|
+
# Enable threaded mode
|
44
|
+
# config.threadsafe!
|
45
|
+
|
46
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
47
|
+
# the I18n.default_locale when a translation can not be found)
|
48
|
+
config.i18n.fallbacks = true
|
49
|
+
|
50
|
+
# Send deprecation notices to registered listeners
|
51
|
+
config.active_support.deprecation = :notify
|
52
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.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
|
+
# Raise exceptions instead of rendering exception templates
|
18
|
+
config.action_dispatch.show_exceptions = false
|
19
|
+
|
20
|
+
# Disable request forgery protection in test environment
|
21
|
+
config.action_controller.allow_forgery_protection = false
|
22
|
+
|
23
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
24
|
+
# The :test delivery method accumulates sent emails in the
|
25
|
+
# ActionMailer::Base.deliveries array.
|
26
|
+
config.action_mailer.delivery_method = :test
|
27
|
+
|
28
|
+
# Use SQL instead of Active Record's schema dumper when creating the test database.
|
29
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
30
|
+
# like if you have constraints or database-specific column types
|
31
|
+
# config.active_record.schema_format = :sql
|
32
|
+
|
33
|
+
# Print deprecation notices to the stderr
|
34
|
+
config.active_support.deprecation = :stderr
|
35
|
+
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,10 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Add new inflection rules using the following format
|
4
|
+
# (all these examples are active by default):
|
5
|
+
# ActiveSupport::Inflector.inflections do |inflect|
|
6
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
7
|
+
# inflect.singular /^(ox)en/i, '\1'
|
8
|
+
# inflect.irregular 'person', 'people'
|
9
|
+
# inflect.uncountable %w( fish sheep )
|
10
|
+
# end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
# Make sure the secret is at least 30 characters and all random,
|
6
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
7
|
+
Dummy::Application.config.secret_token = '0e1ff253dd4b2099914d98c8d0f6246ec37b88806e3b3b090c6ac259f506d663205d27038602cb808e667789859c05779933a6462e034240253d91443828cdd2'
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
Dummy::Application.config.session_store :cookie_store, :key => '_dummy_session'
|
4
|
+
|
5
|
+
# Use the database for sessions instead of the cookie-based default,
|
6
|
+
# which shouldn't be used to store highly confidential information
|
7
|
+
# (create the session table with "rails generate session_migration")
|
8
|
+
# Dummy::Application.config.session_store :active_record_store
|
@@ -0,0 +1,9 @@
|
|
1
|
+
class ActionMailer::Base
|
2
|
+
def from_with_default(input=nil)
|
3
|
+
return from_without_default(input) || "default@dummy.com" if input.nil?
|
4
|
+
from_without_default(input)
|
5
|
+
end
|
6
|
+
alias_method_chain :from, :default
|
7
|
+
end
|
8
|
+
|
9
|
+
Mail.register_interceptor(DevelopmentMailInterceptor) if Rails.env.development?
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class CreateUsers < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :users do |t|
|
4
|
+
t.string :email, :null => false
|
5
|
+
t.string :name, :limit => 100, :null => false
|
6
|
+
t.string :location, :limit => 150
|
7
|
+
t.string :crypted_password, :null => false
|
8
|
+
t.string :password_salt, :null => false
|
9
|
+
t.string :persistence_token, :null => false
|
10
|
+
t.string :single_access_token, :null => false
|
11
|
+
t.string :perishable_token, :null => false
|
12
|
+
t.integer :login_count, :null => false, :default => 0
|
13
|
+
t.integer :failed_login_count, :null => false, :default => 0
|
14
|
+
t.datetime :last_request_at
|
15
|
+
t.datetime :current_login_at
|
16
|
+
t.datetime :last_login_at
|
17
|
+
t.string :current_login_ip
|
18
|
+
t.string :last_login_ip
|
19
|
+
t.timestamps
|
20
|
+
end
|
21
|
+
add_index :users, :email, :unique => true
|
22
|
+
add_index :users, :perishable_token
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.down
|
26
|
+
drop_table :users
|
27
|
+
end
|
28
|
+
end
|