Skip to content

Instantly share code, notes, and snippets.

@jimmyz
Created August 22, 2011 17:00
Show Gist options
  • Save jimmyz/1162903 to your computer and use it in GitHub Desktop.
Save jimmyz/1162903 to your computer and use it in GitHub Desktop.
familysearch_controller stuff
def catch_authentication
yield
rescue RubyFsStack::Unauthorized => e
if e.message =~ /401\.23/ # Unauthorized
serialize_request
please_authenticate
elsif e.message =~ /401\.1/ # Bad Credentials
@message = "Invalid credentials. Please try again."
please_authenticate
else
raise e
end
rescue Exception => e
if e.message == 'Unauthorized'
serialize_request
please_authenticate
else
raise e
end
end
def please_authenticate
@fs_user = FamilySearchUser.new
session[:ft_session] = nil
respond_to do |format|
format.js {render :partial => 'authenticate'}
format.html {render :action => 'authenticate'}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment