Sha256: 50d23ca92d32753b89ce73874fb409ff7c5eee2d92e90cc3cbfc6a2e31ec453c
Contents?: true
Size: 791 Bytes
Versions: 1
Compression:
Stored size: 791 Bytes
Contents
require 'json' require 'curb' module Dx class Auth def self.login(email,password) payload = { user: { email: email, password: password } } http = Curl.post('http://localhost:5000/login.json', payload.to_json ) do |curl| curl.headers['Content-Type'] = 'application/json' curl.headers['Accept'] = '*/*' end return parse(email,JSON.parse(http.body_str)) end def self.parse(email,auth) begin if auth['email'] == email && auth['token'] open("#{ENV['HOME']}/deemx.token", 'w') { |f| f << auth['token'] } return true else return false end rescue JSON::ParserError => e return false end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dx-0.1.0 | lib/dx/auth.rb |