1 class Auth < ActiveRecord::Base
4 #scope :hash, lambda {|hash| {
5 # :joins => {:membership_messages => {:membership => :participant}},
7 # :conditions => {:participants => {:id => participant.id}}}}
10 # if valid time window return true
11 def test_validation_window
12 b = JSON.parse(message.body)
13 sov = Time.parse(b["sov"])
14 eov = Time.parse(b["eov"])
22 # garbage collect outtimed authorization tokens
24 gc_sys_auths_lock= "#{Rails.root}/tmp/gc_sys_auths.lock"
25 if File.exists?(gc_sys_auths_lock)
26 logtext= "GC: there seems to be already running a ecs:gc_sys_auths process (#{gc_sys_auths_lock}). Aborting."
28 puts logtext unless Rails.env.test?
31 File.open(gc_sys_auths_lock,"w") do |f|
32 f.puts "#{Process.pid}"
34 logtext= "GC: Searching for outtimed auths ..."
36 puts logtext unless Rails.env.test?
37 Auth.all.each do |auth|
38 if ! auth.test_validation_window
39 auth.message.destroy_as_sender
40 logtext= "GC: garbage collect auths token: #{auth.one_touch_hash}"
42 puts logtext unless Rails.env.test?
45 logtext= "GC: Searching for outtimed auths done."
47 puts logtext unless Rails.env.test?
50 File.delete(gc_sys_auths_lock)