session.rb 675 B

1234567891011121314151617181920212223242526
  1. # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
  2. class Observer::Session < ActiveRecord::Observer
  3. observe 'active_record::_session_store::_session'
  4. def before_create(record)
  5. check(record)
  6. end
  7. def before_update(record)
  8. check(record)
  9. end
  10. # move the persistent attribute from the sub structure
  11. # to the first level so it gets stored in the database
  12. # column to make the cleanup lookup more performant
  13. def check(record)
  14. return if !record.data
  15. return if record[:persistent]
  16. return if !record.data['persistent']
  17. record[:persistent] = record.data['persistent']
  18. record.data.delete('persistent')
  19. end
  20. end