Skip to content

Commit

Permalink
Update twitter oauth_token and oauth_secret so that if we change, say…
Browse files Browse the repository at this point in the history
…, twitter keys or permissions, the user's credentials that we use when we try to post will be the latest ones that they approved.
  • Loading branch information
carols10cents committed Dec 12, 2011
1 parent 843d66a commit 6891866
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
13 changes: 5 additions & 8 deletions app/controllers/auth_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,12 @@ def auth

# If an authorization is present then it is assumed to be a successful
# authentication. The oauth credentials for the user in question are checked
# and stored if not present (this is to provide oauth credentials for legacy
# users).
# and updated.

if @auth.oauth_token.nil?
@auth.oauth_token = auth['credentials']['token']
@auth.oauth_secret = auth['credentials']['secret']
@auth.nickname = auth['user_info']['nickname']
@auth.save
end
@auth.oauth_token = auth['credentials']['token']
@auth.oauth_secret = auth['credentials']['secret']
@auth.nickname = auth['user_info']['nickname']
@auth.save

session[:user_id] = @auth.user.id

Expand Down
4 changes: 2 additions & 2 deletions test/acceptance/acceptance_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ def omni_error_mock(message, options={})
OmniAuth.config.mock_auth[provider] = message.to_sym
end

def log_in(user, uid = 12345)
def log_in(user, uid = 12345, options={})
if user.is_a? User
user = user.username
end

omni_mock(user, {:uid => uid})
omni_mock(user, {:uid => uid}.merge(options))

visit '/auth/twitter'
end
Expand Down
2 changes: 1 addition & 1 deletion test/acceptance/auth_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def log_in_new_email_user
it "shows twitter nickname if twitter auth" do
u = Factory(:user)
a = Factory(:authorization, :user => u, :nickname => "Awesomeo the Great")
log_in(u, a.uid)
log_in(u, a.uid, :nickname => a.nickname)
visit "/users/#{u.username}/edit"

assert_match page.body, /Awesomeo the Great/
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def auth_response(username, options={})
"user_info" => {
"name" => "Joe Public",
"email" => "[email protected]",
"nickname" => username,
"nickname" => options[:nickname] || username,
"urls" => { "Website" => "http://rstat.us" },
"description" => "A description",
"image" => "/images/something.png"
Expand Down

0 comments on commit 6891866

Please sign in to comment.