Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
Add Comment
Please, Sign In to add comment