Class: FlyAdmin::Imbs::ConnectionApi

Inherits:
Object
  • Object
show all
Defined in:
lib/fly_admin/imbs/connection_api.rb

Class Method Summary collapse

Class Method Details

.check_user(user) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 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