All,
I have a view which, onload, executes some JQuery code to populate a select_tag box:
var request = $.get("getLocalSuites");
getLocalSuites routes to the following function in the controller:
def getLocal
myPass = sessionPass
if (myPass != nil)
puts "4"
result = @@p4object.getLocalSuites(sessionUser,myPass)
render :json => result
end
end
Where sessionPass and sessionUser functions are defined:
def sessionUser()
myConnectedUser = ConnectedUser.find_by username: cookies[:username]
return myConnectedUser[:username]
end
def sessionPass()
begin
myConnectedUser = ConnectedUser.find_by username: cookies[:username]
puts "1"
verifier = ActiveSupport::MessageVerifier.new(cookies[:session])
puts "2"
mysession = verifier.verify(myConnectedUser[:password])
rescue ActiveSupport::MessageVerifier::InvalidSignature
puts "3"
redirect_to sign_in_session_expired_url
end
puts mysession
return mysession
end
So in other words - my jQuery calls getLocal, which finds a username and password stored in the DB. It then verifies the returned encrypted password against a session cookie. If this verification fails, it should redirect back to the sign in page, rather than try to continue to render the current page.
The server log is correctly showing Redirected to http://localhost:3000/sign_in_session_expired
... but rather than seeing the sign in screen, the "original" view (with select_tag etc) is rendered - with the LocalSuites select_tag populated with some sort of HTML - each character as a new row: <!DOCTYPE html> <html etc etc
Can anyone explain what I am misunderstanding here - why my redirect appears to work (according to server log) - but doesn't actually happen?
Thanks!