Skip to content

Commit

Permalink
Omniauth now returns "info" instead of "user_info"
Browse files Browse the repository at this point in the history
  • Loading branch information
carols10cents committed Aug 13, 2012
1 parent c7a9fbd commit 8634052
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
16 changes: 8 additions & 8 deletions app/controllers/auth_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@ def auth
# might be a nice refactoring.
session[:uid] = auth['uid']
session[:provider] = auth['provider']
session[:name] = auth['user_info']['name']
session[:nickname] = auth['user_info']['nickname']
session[:website] = auth['user_info']['urls']['Website']
session[:description] = auth['user_info']['description']
session[:image] = auth['user_info']['image']
session[:email] = auth['user_info']['email']
session[:name] = auth['info']['name']
session[:nickname] = auth['info']['nickname']
session[:website] = auth['info']['urls']['Website']
session[:description] = auth['info']['description']
session[:image] = auth['info']['image']
session[:email] = auth['info']['email']
session[:oauth_token] = auth['credentials']['token']
session[:oauth_secret] = auth['credentials']['secret']

# The username is checked to ensure it is unique, if it is not,
# the user is informed that they need to change it.
# Everyone is redirected to /users/new to confirm that they'd like
# to have their username.
if User.first :username => auth['user_info']['nickname']
if User.first :username => auth['info']['nickname']
flash[:error] = "Sorry, someone else has that username. Please pick another."
end

Expand All @@ -55,7 +55,7 @@ def auth

@auth.oauth_token = auth['credentials']['token']
@auth.oauth_secret = auth['credentials']['secret']
@auth.nickname = auth['user_info']['nickname']
@auth.nickname = auth['info']['nickname']
@auth.save

session[:user_id] = @auth.user.id
Expand Down
2 changes: 1 addition & 1 deletion app/models/author.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class Author
def self.create_from_hash!(hash, domain)

# Omniauth user information, as a hash
user = hash['user_info']
user = hash['info']

# Grabs each of the important user details
name = user['name']
Expand Down
2 changes: 1 addition & 1 deletion app/models/authorization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def self.create_from_hash!(hash, base_uri, user = nil)
end

# Grab the user information from the hash
uid, provider, nickname = hash['uid'], hash['provider'], hash['user_info']['nickname']
uid, provider, nickname = hash['uid'], hash['provider'], hash['info']['nickname']

# Grab the credentials, including token and secret, from the hash
credentials = hash['credentials']
Expand Down
2 changes: 1 addition & 1 deletion test/models/author_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
end

it "creates an author from a hash" do
hash = {"user_info" => {"name" => "james", "nickname" => "jim", "urls" => {}} }
hash = {"info" => {"name" => "james", "nickname" => "jim", "urls" => {}} }
assert Author.create_from_hash!(hash, "rstat.us").is_a?(Author)
end

Expand Down
2 changes: 1 addition & 1 deletion test/models/authorization_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

assert_equal auth["uid"], a.uid
assert_equal auth["provider"], a.provider
assert_equal auth["user_info"]["nickname"], a.nickname
assert_equal auth["info"]["nickname"], a.nickname
assert_equal auth['credentials']['token'], a.oauth_token
assert_equal auth['credentials']['secret'], a.oauth_secret
end
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def auth_response(username, options={})
{
"provider" => options[:provider] || "twitter",
"uid" => options[:uid] || 12345,
"user_info" => {
"info" => {
"name" => "Joe Public",
"email" => "[email protected]",
"nickname" => options[:nickname] || username,
Expand Down

0 comments on commit 8634052

Please sign in to comment.