Replace PrototypeR4 by Orbit.

Move session into mongoid_store.
Reset session when sing_in.
This commit is contained in:
Christophe Vilayphiou 2012-03-05 16:19:08 +08:00
parent 785ead5209
commit f4fda08e86
16 changed files with 69 additions and 18 deletions

View File

@ -1,6 +1,8 @@
source 'http://rubygems.org'
gem 'rails', '>=3.1.0', '<3.2.0'
gem "brakeman"
gem 'bson_ext'
gem 'carrierwave'
gem 'carrierwave-mongoid', :require => 'carrierwave/mongoid'
@ -13,6 +15,7 @@ gem 'kaminari', :git => 'git://github.com/amatsuda/kaminari.git'
gem 'mini_magick'
gem 'mongoid'
gem "mongo_session_store-rails3"
gem 'radius'
gem 'rake'
gem 'ruby-debug19'

View File

@ -42,6 +42,14 @@ GEM
arel (2.2.1)
bcrypt-ruby (3.0.1)
bcrypt-ruby (3.0.1-x86-mingw32)
brakeman (1.5.0)
activesupport
erubis (~> 2.6)
haml (~> 3.0)
i18n
ruby2ruby (~> 1.2)
ruport (~> 1.6)
sass (~> 3.0)
bson (1.5.2)
bson_ext (1.5.2)
bson (= 1.5.2)
@ -59,6 +67,7 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.2.0)
color (1.4.1)
columnize (0.3.6)
database_cleaner (0.7.1)
delorean (1.2.0)
@ -78,7 +87,11 @@ GEM
factory_girl_rails (1.6.0)
factory_girl (~> 2.5.0)
railties (>= 3.0.0)
fastercsv (1.5.4)
haml (3.1.4)
hike (1.2.1)
hoe (2.15.0)
rake (~> 0.8)
i18n (0.6.0)
jquery-rails (1.0.19)
railties (~> 3.0)
@ -96,12 +109,18 @@ GEM
subexec (~> 0.2.1)
mongo (1.5.2)
bson (= 1.5.2)
mongo_session_store-rails3 (3.0.5)
actionpack (>= 3.0)
mongo
mongoid (2.4.2)
activemodel (~> 3.1)
mongo (~> 1.3)
tzinfo (~> 0.3.22)
multi_json (1.0.4)
orm_adapter (0.0.6)
pdf-writer (1.1.8)
color (>= 1.4.0)
transaction-simple (~> 1.3)
polyglot (0.3.3)
rack (1.3.6)
rack-cache (1.1)
@ -154,15 +173,24 @@ GEM
columnize (>= 0.3.1)
linecache19 (>= 0.5.11)
ruby-debug-base19 (>= 0.11.19)
ruby2ruby (1.3.1)
ruby_parser (~> 2.0)
sexp_processor (~> 3.0)
ruby_core_source (0.1.5)
archive-tar-minitar (>= 0.5.2)
ruby_parser (2.3.1)
sexp_processor (~> 3.0)
rubyzip (0.9.5)
ruport (1.6.3)
fastercsv
pdf-writer (= 1.1.8)
sass (3.1.12)
sass-rails (3.1.5)
actionpack (~> 3.1.0)
railties (~> 3.1.0)
sass (~> 3.1.10)
tilt (~> 1.3.2)
sexp_processor (3.1.0)
shoulda-matchers (1.0.0)
simplecov (0.5.4)
multi_json (~> 1.0.3)
@ -186,6 +214,8 @@ GEM
tilt (1.3.3)
tinymce-rails (3.4.8)
railties (>= 3.1)
transaction-simple (1.4.0)
hoe (>= 1.1.7)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
@ -210,6 +240,7 @@ PLATFORMS
x86-mingw32
DEPENDENCIES
brakeman
bson_ext
carrierwave
carrierwave-mongoid
@ -223,6 +254,7 @@ DEPENDENCIES
jquery-rails
kaminari!
mini_magick
mongo_session_store-rails3
mongoid
radius
rails (>= 3.1.0, < 3.2.0)

View File

@ -5,4 +5,4 @@ require File.expand_path('../config/application', __FILE__)
require 'rake/dsl_definition'
require 'rake'
PrototypeR4::Application.load_tasks
Orbit::Application.load_tasks

View File

@ -0,0 +1,8 @@
class SessionsController < Devise::SessionsController
def create
super
reset_session
end
end

12
app/models/session.rb Normal file
View File

@ -0,0 +1,12 @@
class Session
include Mongoid::Document
include Mongoid::Timestamps
def self.sweep(time = 1.hour)
if time.is_a?(String)
time = time.split.inject { |count, unit| count.to_i.send(unit) }
end
delete_all "updated_at < '#{time.ago.to_s(:db)}' OR created_at < '#{2.days.ago.to_s(:db)}'"
end
end

View File

@ -1,4 +1,4 @@
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run PrototypeR4::Application
run Orbit::Application

View File

@ -13,12 +13,13 @@ require 'sprockets/railtie'
# or test environments.
Bundler.require *Rails.groups(:assets) if defined?(Bundler)
module PrototypeR4
module Orbit
class Application < Rails::Application
# Add directories for plugins
config.paths["vendor/plugins"] += %W(#{config.root}/vendor/built_in_modules)
config.paths["vendor/plugins"] += %W(#{config.root}/vendor/downloaded_modules)
config.paths.app.views << "app/views/devise"
# Settings in config/environments/* take precedence over those specified here.

View File

@ -4,4 +4,4 @@ require 'yaml'
YAML::ENGINE.yamler = 'syck'
# Initialize the rails application
PrototypeR4::Application.initialize!
Orbit::Application.initialize!

View File

@ -1,4 +1,4 @@
PrototypeR4::Application.configure do
Orbit::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# In the development environment your application's code is reloaded on

View File

@ -1,4 +1,4 @@
PrototypeR4::Application.configure do
Orbit::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# The production environment is meant for finished, "live" apps.

View File

@ -1,4 +1,4 @@
PrototypeR4::Application.configure do
Orbit::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# The test environment is used exclusively to run your application's

View File

@ -4,4 +4,4 @@
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
PrototypeR4::Application.config.secret_token = 'cbf6409102b30cb9f4da455ee08c3a7e9d8b2a3d32a0e5b59a354dad03f469d363a8127ef4b7bc3b1afa632d7cf947a1e59e09022d2d4cd8df1f4fa521d7ec07'
Orbit::Application.config.secret_token = 'cbf6409102b30cb9f4da455ee08c3a7e9d8b2a3d32a0e5b59a354dad03f469d363a8127ef4b7bc3b1afa632d7cf947a1e59e09022d2d4cd8df1f4fa521d7ec07'

View File

@ -4,4 +4,4 @@
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
PrototypeR4::Application.config.secret_token = 'b8d78ecaf3086ebfc1ba42e912acba60d85cf3d789d933e117770e1a045a12911f121ff012a234982abb446c8b8c768052eea4bf8b2d5d336be821e2c25d8cdb'
Orbit::Application.config.secret_token = 'b8d78ecaf3086ebfc1ba42e912acba60d85cf3d789d933e117770e1a045a12911f121ff012a234982abb446c8b8c768052eea4bf8b2d5d336be821e2c25d8cdb'

View File

@ -1,8 +1,3 @@
# Be sure to restart your server when you modify this file.
PrototypeR4::Application.config.session_store :cookie_store, :key => '_prototype_R4_session'
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table with "rails generate session_migration")
# PrototypeR4::Application.config.session_store :active_record_store
Orbit::Application.config.session_store :mongoid_store

View File

@ -1,4 +1,4 @@
PrototypeR4::Application.routes.draw do
Orbit::Application.routes.draw do
devise_for :users

View File

@ -3,7 +3,7 @@
# # Add a load path for this specific Engine
# # config.autoload_paths << File.expand_path("../lib/some/path", __FILE__)
# put "ABC"
# PrototypeR4::Application::Orbit_Apps << "NewBlog"
# Orbit::Application::Orbit_Apps << "NewBlog"
#
# # initializer "my_engine.add_middleware" do |app|
# # app.middleware.use MyEngine::Middleware
@ -15,4 +15,4 @@ module NewBlog
VERSION = "0.0.1"
MOUDLEAPP_TITLE = "NewBlog"
end
# PrototypeR4::Application::Orbit_Apps << "NewBlog"
# Orbit::Application::Orbit_Apps << "NewBlog"