Created
August 22, 2011 17:00
-
-
Save jimmyz/1162903 to your computer and use it in GitHub Desktop.
familysearch_controller stuff
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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