Sha256: ac1cbf258739de56560a820acb55b3b6b0a88ec00ad26c3f6fde13d78a798cda

Contents?: true

Size: 911 Bytes

Versions: 2

Compression:

Stored size: 911 Bytes

Contents

module FatFreeCRM
  module Cloudfuji
    module EventObservers
      class AppObserver < ::Cloudfuji::EventObserver
        def app_claimed
          puts "Updating #{User.first.inspect} with incoming data #{params.inspect}"
          puts "Authlogic username column: #{::Authlogic::Cas.cas_username_column}="
          puts "Setting username to: #{params.try(:[], 'ido_id')}"

          user = User.first
          if user
            data = params['data']

            user.email      = data['email']
            user.first_name = user.email.split('@').first
            user.last_name  = user.email.split('@').last
            user.username   = data['email']
            user.deleted_at = nil
            user.send("#{::Authlogic::Cas.cas_username_column}=".to_sym, params['data'].try(:[], 'ido_id'))
            puts user.inspect
            user.save!
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ffcrm_cloudfuji-0.1.4 lib/fat_free_crm/cloudfuji/event_observers/app_observer.rb
ffcrm_cloudfuji-0.1.3 lib/fat_free_crm/cloudfuji/event_observers/app_observer.rb