Skip to content

Instantly share code, notes, and snippets.

@hwrdprkns
Created December 28, 2010 02:12
Show Gist options
  • Save hwrdprkns/756800 to your computer and use it in GitHub Desktop.
Save hwrdprkns/756800 to your computer and use it in GitHub Desktop.
httparty problem
class SessionsController < ApplicationController
@base_uri = 'service.hwrdprkns.com:8080/'
def new
@title = 'Sign In'
end
def create
if params[:session][:email].blank? || params[:session][:password].blank?
flash[:error] = 'You must fill out both fields.'
@title = 'Sign In'
redirect_to '/signin'
end
vendor = authenticate(params[:session][:email],params[:session][:password])
if vendor.nil?
flash.now[:error] = 'Invalid email and password combination.'
redirect_to '/signin'
else
#redirect user to show page.
end
end
def authenticate(email,password)
key = Base64.encode64(email+':'+password)
params_hash = {:headers => {:authentication =>'Basic '+key}}
response = HTTParty.get(@base_uri+'vendors/verifyVendorCredentials', params_hash)
raise response
end
def destroy
sign_out
redirect_to root_path
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment