Created
August 6, 2015 00:32
-
-
Save Marahin/66c1bc2a2346ae3b54d8 to your computer and use it in GitHub Desktop.
This file contains 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
root :to => 'home#index' | |
#sessions | |
post 'auth/:provider/callback' => 'sessions#create' | |
post 'auth/failure', :to => 'sessions#failure' |
This file contains 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 | |
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