Sha256: de84315499a10e6b15d3a0121a2f036324bbff6c4a0aa1da4c87b21097f95b06
Contents?: true
Size: 1.34 KB
Versions: 2
Compression:
Stored size: 1.34 KB
Contents
class Tane::Helpers::Bushido include Tane::Helpers class << self def bushido_url ENV['BUSHIDO_URL'] || "http://bushi.do" end # Returns nil if credentials are invalid # Returns the authentication_token if credentials are valid def verify_credentials(email, password) begin result = JSON(RestClient.get("#{bushido_url}/users/verify.json", { :params => {:email => email, :password => password }})) if result['errors'].nil? return result['authentication_token'], nil else return nil, result['errors'] end rescue => e return nil, ["Couldn't login with those credentials!"] end end def signup(email, password) term.say "Contacting bushido..." term.say "(using #{bushido_url}/users/create.json)" begin result = JSON(RestClient.get("#{bushido_url}/users/create.json", { :params => {:email => email, :password => password }})) if result['errors'].nil? return result['authentication_token'], nil else return nil, result['errors'] end rescue => e if e.respond_to?(:http_body) return nil, [["", [JSON(e.http_body)['error']]]] end return nil end end def authenticate_user(email, password) warn_if_credentials end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tane-0.0.2 | lib/tane/helpers/bushido_helper.rb |
tane-0.0.1 | lib/tane/helpers/bushido_helper.rb |