Skip to content

Instantly share code, notes, and snippets.

@Marahin
Created August 6, 2015 00:32
Show Gist options
  • Save Marahin/66c1bc2a2346ae3b54d8 to your computer and use it in GitHub Desktop.
Save Marahin/66c1bc2a2346ae3b54d8 to your computer and use it in GitHub Desktop.
root :to => 'home#index'
#sessions
post 'auth/:provider/callback' => 'sessions#create'
post 'auth/failure', :to => 'sessions#failure'
class SessionsController < ApplicationController
protect_from_forgery with: :null_session
def create
puts request.env['omniauth.auth']
usr = User.new( auth_params )
unless User.find_by(:steamid => usr.steamid )
User.create( usr )
end
session[:user_session_id] = usr.steamid
redirect_to '/'
end
def failure
end
protected
def auth_params
h = Hash.new()
# poor way to merge it, a temporary solution that works #
h[:steamid] = request.env['omniauth.auth'].uid
h[:nickname] = request.env['omniauth.auth'].info.nickname
h[:name] = request.env['omniauth.auth'].info.name
h[:image] = request.env['omniauth.auth'].info.image
h[:profile]= request.env['omniauth.auth'].extra.raw_info.profileurl
h
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment