Skip to content

Commit

Permalink
initial checkin
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismatthieu committed Jun 30, 2011
0 parents commit e93dd58
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Gemfile
@@ -0,0 +1,2 @@
gem 'sinatra'
gem 'omniauth'
2 changes: 2 additions & 0 deletions config.ru
@@ -0,0 +1,2 @@
require 'githubchat'
run Sinatra::Application
40 changes: 40 additions & 0 deletions githubchat.rb
@@ -0,0 +1,40 @@
begin
require 'sinatra'
require 'omniauth'
rescue LoadError
require 'rubygems'
require 'sinatra'
require 'omniauth'
end

use Rack::Session::Cookie
use OmniAuth::Builder do
provider :github, '74a1475d7f5564343099', 'f8310520720f56e931f086d519c435d800c6997a'
end

get '/' do
<<-HTML
<a href='/auth/github'>Sign in with GitHub</a>
HTML
end

post '/auth/:name/callback' do
omniauth = request.env['omniauth.auth']
# do whatever you want with the information!
end

get '/auth/:name/callback' do
omniauth = request.env['omniauth.auth']

# create a new hash
@authhash = Hash.new

omniauth['user_info']['email'] ? @authhash[:email] = omniauth['user_info']['email'] : @authhash[:email] = ''
omniauth['user_info']['name'] ? @authhash[:name] = omniauth['user_info']['name'] : @authhash[:name] = ''
omniauth['extra']['user_hash']['id'] ? @authhash[:uid] = omniauth['extra']['user_hash']['id'].to_s : @authhash[:uid] = ''
omniauth['provider'] ? @authhash[:provider] = omniauth['provider'] : @authhash[:provider] = ''

# session[:user] = @authhash

end

0 comments on commit e93dd58

Please sign in to comment.