Created
December 28, 2010 02:12
-
-
Save hwrdprkns/756800 to your computer and use it in GitHub Desktop.
httparty problem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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