Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adding omniauth initializer with GitHub provider

  • Loading branch information...
commit d5874803459d2bda2e0b1a0e5440def4afc8411c 1 parent 37a9954
@ryanb authored
View
1  Gemfile
@@ -9,6 +9,7 @@ gem "thinking-sphinx", ">= 2.0.1", :require => "thinking_sphinx"
gem "whenever", :require => false
gem "will_paginate", ">= 3.0.pre2"
gem "jquery-rails"
+gem "omniauth"
group :development, :test do
gem "mocha"
View
52 Gemfile.lock
@@ -32,6 +32,7 @@ GEM
activesupport (= 3.0.3)
activesupport (3.0.3)
acts_as_list (0.1.2)
+ addressable (2.2.2)
arel (2.0.3)
autotest (4.4.1)
autotest-rails (4.1.0)
@@ -45,6 +46,10 @@ GEM
factory_girl_rails (1.0)
factory_girl (~> 1.3)
rails (>= 3.0.0.beta4)
+ faraday (0.5.3)
+ addressable (~> 2.2.2)
+ multipart-post (~> 1.0.1)
+ rack (>= 1.1.0, < 2)
i18n (0.4.2)
jquery-rails (0.2.5)
rails (~> 3.0)
@@ -57,13 +62,53 @@ GEM
mime-types (1.16)
mocha (0.9.9)
rake
+ multi_json (0.0.5)
+ multipart-post (1.0.1)
mysql2 (0.2.6)
+ net-ldap (0.1.1)
nifty-generators (0.4.2)
nokogiri (1.4.4)
+ oa-basic (0.1.6)
+ multi_json (~> 0.0.2)
+ nokogiri (~> 1.4.2)
+ oa-core (= 0.1.6)
+ rest-client (~> 1.6.0)
+ oa-core (0.1.6)
+ rack (~> 1.1)
+ oa-enterprise (0.1.6)
+ net-ldap (~> 0.1.1)
+ nokogiri (~> 1.4.2)
+ oa-core (= 0.1.6)
+ pyu-ruby-sasl (~> 0.0.3.1)
+ rubyntlm (~> 0.1.1)
+ oa-oauth (0.1.6)
+ multi_json (~> 0.0.2)
+ nokogiri (~> 1.4.2)
+ oa-core (= 0.1.6)
+ oauth (~> 0.4.0)
+ oauth2 (~> 0.1.0)
+ oa-openid (0.1.6)
+ oa-core (= 0.1.6)
+ rack-openid (~> 1.2.0)
+ ruby-openid-apps-discovery
+ oauth (0.4.4)
+ oauth2 (0.1.0)
+ faraday (~> 0.5.0)
+ multi_json (~> 0.0.4)
+ omniauth (0.1.6)
+ oa-basic (= 0.1.6)
+ oa-core (= 0.1.6)
+ oa-enterprise (= 0.1.6)
+ oa-oauth (= 0.1.6)
+ oa-openid (= 0.1.6)
polyglot (0.3.1)
+ pyu-ruby-sasl (0.0.3.2)
rack (1.2.1)
rack-mount (0.6.13)
rack (>= 1.0.0)
+ rack-openid (1.2.0)
+ rack (>= 1.1.0)
+ ruby-openid (>= 2.1.8)
rack-test (0.5.6)
rack (>= 1.0)
rails (3.0.3)
@@ -80,6 +125,8 @@ GEM
rake (>= 0.8.7)
thor (~> 0.14.4)
rake (0.8.7)
+ rest-client (1.6.1)
+ mime-types (>= 1.16)
riddle (1.2.1)
rspec (2.1.0)
rspec-core (~> 2.1.0)
@@ -91,6 +138,10 @@ GEM
rspec-mocks (2.1.0)
rspec-rails (2.1.0)
rspec (~> 2.1.0)
+ ruby-openid (2.1.8)
+ ruby-openid-apps-discovery (1.2.0)
+ ruby-openid (>= 2.1.7)
+ rubyntlm (0.1.1)
thinking-sphinx (2.0.1)
activerecord (>= 3.0.3)
riddle (>= 1.2.1)
@@ -121,6 +172,7 @@ DEPENDENCIES
mocha
mysql2
nifty-generators
+ omniauth
rails (= 3.0.3)
rspec-rails
thinking-sphinx (>= 2.0.1)
View
1  app/controllers/users_controller.rb
@@ -7,6 +7,7 @@ def show
def create
omniauth = request.env["omniauth.auth"]
+ logger.info omniauth.inspect
@user = User.find_by_github_username(omniauth["uid"]) || User.create_from_omniauth(omniauth)
cookies.permanent[:token] = @user.token
redirect_to root_url, :notice => "Signed in successfully"
View
35 app/views/users/show.html.erb
@@ -1,34 +1,3 @@
-<% title "User" %>
+<% title "User #{@user.name}" %>
-<p>
- <strong>Token:</strong>
- <%= @user.token %>
-</p>
-<p>
- <strong>Name:</strong>
- <%= @user.name %>
-</p>
-<p>
- <strong>Github Username:</strong>
- <%= @user.github_username %>
-</p>
-<p>
- <strong>Email:</strong>
- <%= @user.email %>
-</p>
-<p>
- <strong>Site Url:</strong>
- <%= @user.site_url %>
-</p>
-<p>
- <strong>Avatar Url:</strong>
- <%= @user.avatar_url %>
-</p>
-<p>
- <strong>Admin:</strong>
- <%= @user.admin %>
-</p>
-
-<p>
- <%= link_to "Edit", edit_user_path(@user) %> |
-</p>
+<p>Profile details coming soon.</p>
View
4 config/examples/app_config.yml
@@ -3,4 +3,6 @@ session_key: "_railscasts_session"
session_secret: 40bc73b6a7be494f7de7d9d3b27a3cd81b1d7857f1fbc48445222d728677cb2378f93a96b780542d9fbf92bc18725556d3320ef4d21f4394b7c6b9f94705f78b
thinking_sphinx: false
hoptoad_key: false
-spam_key: anythingsecret
+spam_key: anything_secret
+github_id: oauth_id
+github_secret: oauth_secret
View
4 config/initializers/omniauth.rb
@@ -0,0 +1,4 @@
+Rails.application.config.middleware.use OmniAuth::Builder do
+ # Sign up at https://github.com/account/applications
+ provider :github, APP_CONFIG["github_id"], APP_CONFIG["github_secret"]
+end
Please sign in to comment.
Something went wrong with that request. Please try again.