Permalink
Browse files

Use the latest mongoid gem. Fix cleanup_nonces.

  • Loading branch information...
dylanegan committed Jun 14, 2010
1 parent 98d3367 commit e1a345eeb327496e9747b32ef70268026b723e89
Showing with 9 additions and 2 deletions.
  1. +1 −1 Gemfile
  2. +8 −1 lib/openid/store/mongoid.rb
View
@@ -2,7 +2,7 @@ source :rubygems
gem 'ruby-openid', '~> 2.1.7'
gem 'bson_ext', '~> 1.0.1'
-gem 'mongoid', '~> 1.9.0'
+gem 'mongoid', '2.0.0.beta6'
group :rake do
gem 'rake'
@@ -48,11 +48,18 @@ def use_nonce(server_url, timestamp, salt)
def cleanup_nonces
now = Time.now.to_i
- OpenIDStoreMongoid::Nonce.destroy_all(:conditions => { :timestamp.gt => (now + OpenID::Nonce.skew), :timestamp.lt => (now - OpenID::Nonce.skew) })
+ count = 0
+ # Some weird bug with .destroy_all(:conditions => {:timestamp.gt => (now + OpenID::Nonce.skew), :timestamp.lt => (now - OpenID::Nonce.skew)})
+ OpenIDStoreMongoid::Nonce.where(:timestamp.gt => (now + OpenID::Nonce.skew)).and(:timestamp.lt => (now - OpenID::Nonce.skew)).each do |nonce|
+ nonce.destroy
+ count += 1
+ end
+ count
end
def cleanup_associations
count = 0
+ # Not sure how to do this in Mongo, maybe someone can show me?
OpenIDStoreMongoid::Association.all(:conditions => { :issued.gt => 0 }).each do |association|
if association.lifetime + association.issued > Time.now.to_i
association.destroy

0 comments on commit e1a345e

Please sign in to comment.