lib/plezi/oauth/auth_controller.rb in plezi-0.10.17 vs lib/plezi/oauth/auth_controller.rb in plezi-0.11.0
- old
+ new
@@ -137,11 +137,11 @@
# different login methods, i.e.:
#
# @user ||= app_login || OAuth2Ctrl.auth(:facebook, fb_token, self) || OAuth2Ctrl.auth(:google, google_token, self) || ....
def self.auth service_name, service_token, controller
service = SERVICES[service_name]
- retrun false unless service
+ return false unless service
# auth_res = controller.cookies[c_name] ? (JSON.parse URI.parse("#{service[:profile_url]}?access_token=#{controller.cookies[c_name]}").read rescue ({}) ) : {}
# controller.cookies[c_name] = nil unless auth_res['id']
# auth_res['id'] ? controller.instance_exec( service_name, auth_res['id'], auth_res['email'], auth_res, &auth_callback) : ( controller.instance_exec( service_name, nil, nil, auth_res, &auth_callback) && false)
auth_res = {}
uri = URI.parse("#{service[:profile_url]}?access_token=#{service_token}")
@@ -154,11 +154,11 @@
end
def update
service_name = params[:id].to_s.to_sym
service = SERVICES[service_name]
- retrun false unless service
+ return false unless service
if params[:error]
instance_exec( service_name, nil, nil, nil, {}, &self.class.auth_callback)
return redirect_to(flash[:redirect_after])
end
unless params[:code]
@@ -188,10 +188,10 @@
# this is used internally. Normal behavior would be to set a link to '/auth/{service_name}', where correct redirection will be automatic.
#
def _auth_url_for service_name
service = SERVICES[service_name]
return nil unless service
- redirect_uri = HTTP::encode "#{request.base_url}/auth/#{service_name.to_s}", :url #response_type
+ redirect_uri = Plezi::Base::Helpers.encode_url "#{request.base_url}/auth/#{service_name.to_s}", :url #response_type
return "#{service[:auth_url]}?client_id=#{service[:app_id]}&redirect_uri=#{redirect_uri}&scope=#{service[:scope]}&response_type=code"
end
register_service(:facebook, app_id: ENV['FB_APP_ID'],
app_secret: ENV['FB_APP_SECRET'],