class Dx::Auth
Public Class Methods
login(email,password)
click to toggle source
# File lib/dx/auth.rb, line 8 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
parse(email,auth)
click to toggle source
# File lib/dx/auth.rb, line 22 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