Permalink
Browse files

Fixed bug in deleting authorizations

  • Loading branch information...
1 parent 96a1e54 commit 329a70613c389c93bf69aaa6d0c57ce1ee6911d9 @cjheath committed Aug 17, 2011
Showing with 9 additions and 7 deletions.
  1. +8 −6 lib/sinatra/omniauth.rb
  2. +1 −1 views/auth.haml
View
@@ -155,8 +155,7 @@ def self.registered app
app.get '/auth' do
@authentications_possible = settings.omniauth
- if current_user
- @authentication_current = current_auth
+ if current_user and @authentication_current = current_auth
@authentications_available = current_user.authentications.all(:order => [ :provider.desc ])
@authentications_unused = @authentications_available.
reject do|a|
@@ -282,14 +281,17 @@ def self.registered app
end
# authentication
- app.delete '/auth/:id' do
+ app.delete '/auth/:provider' do
authenticate_user!
# remove an authentication authentication linked to the current user
- @authentication = current_user.authentications.get(params[:id])
+ provider = params[:provider]
+ @authentication = current_user.authentications.first(:provider => provider)
- if session[:authentication_provider] == @authentication.provider
- flash.error = 'You can\'t delete this authorization because you are currently signed in with it!'
+ if !@authentication
+ pass
+ elsif session[:authentication_provider] == @authentication.provider
+ flash.error = 'You can\'t delete your authorization through #{provider.capitalize} because you are currently signed in with it!'
else
@authentication.destroy
end
View
@@ -33,7 +33,7 @@
.authentication.available{:style=>"background-image: url(/images/authbuttons/#{a.provider}_32.png)",:onclick=>"location = '/auth/#{a.provider}';"}
.provider= a.provider.titleize
.uid= a.uid
- %a.remove{:href=>"/auth/#{a.id}", :method => :delete, :rel => 'nofollow', :'data-confirm' => 'Are you sure you want to remove this authentication option?'} x
+ %a.remove{:href=>"/auth/#{a.provider}", :method => :delete, :rel => 'nofollow', :'data-confirm' => 'Are you sure you want to remove this authentication option?'} x
%section.join
- if current_user

0 comments on commit 329a706

Please sign in to comment.