class FlyAdmin::Imbs::ConnectionApi

Public Class Methods

check_user(user) click to toggle source
# File lib/fly_admin/imbs/connection_api.rb, line 4
def self.check_user(user)
  return true if Rails.env == 'development'

  valid = true
  begin
    api_url = SiteConfig['wap_click_addr'] + "/api/check"
    request = RestClient.get(api_url, :params => {:uuid => user.customer_key, :hash => Digest::MD5.hexdigest(user.customer_key + SiteConfig['wc_service_salt']) })
    hash = JSON.parse(request).with_indifferent_access
    
    VALIDATION_LOG.info "status for user #{user.id}: #{hash.inspect}"
    
    valid = false unless hash[:status].eql? true
  rescue Exception => e
    VALIDATION_LOG.error "error check status for user #{user.id}: #{e.message}"
  end
  valid
end