Skip to content

Commit

Permalink
Added more logic to the show method
Browse files Browse the repository at this point in the history
  • Loading branch information
dwilkie committed Jan 29, 2011
1 parent 3f1100d commit cd38de0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions app/controllers/devise/paypal_authentications_controller.rb
Expand Up @@ -22,13 +22,18 @@ def show
if @paypal_authentication.token_param_valid?
@paypal_authentication.get_authentication_details!
else
@paypal_authentication.destroy
url = new_paypal_authentication_path(resource_name)
end
else
url = @paypal_authentication.remote_url
end
end
else
set_flash_message(
:error,
:something_went_wrong_when_contacting_paypal
) if session[:paypal_authentication_id]
url = new_paypal_authentication_path(resource_name)
end
redirect_to url if url
Expand Down
3 changes: 2 additions & 1 deletion app/models/devise/paypal_authentication.rb
Expand Up @@ -5,7 +5,8 @@ class Devise::PaypalAuthentication < ActiveRecord::Base
serialize :params

validates :token,
:uniqueness => true
:uniqueness => true,
:allow_nil => true

def get_authentication_token!(permissions = {})
self.update_attributes!(
Expand Down
5 changes: 2 additions & 3 deletions config/locales/en.yml
@@ -1,6 +1,5 @@
en:
devise:
paypal_authable:
success: "Successfully authorized from Paypal account."
failure: "Unable to authorize you from Paypal account."
paypal_authentications:
something_went_wrong_when_contacting_paypal: "Sorry something went wrong when contacting Paypal. Please try again in a few minutes."

0 comments on commit cd38de0

Please sign in to comment.