9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/crocker.rb', line 9
def self.validate(params)
return unless id_and_password_present?(params)
uri = URI.parse(params.delete(:api_url)||API_URL) rescue ''
signature = Digest::MD5.hexdigest([params.delete(:user_password), params.delete(:secret)||API_SECRET].join) rescue ''
uri.query = URI.encode_www_form({
:userid => params.delete(:user_id),
:signature => signature
}) rescue nil
response = JSON.parse(Net::HTTP.get_response(uri).body.downcase) rescue {}
response['success'] == true ? response['token'].downcase : nil
end
|