Hi,
I have this annoying popup window for Web Password whenever a click on a
javascript action which require authentication. I have the problem for
FF, IE and Chrome. The problem isn't seen for non javascript action
where the user gets redirected to the html login page. Ideally, I want
even js to redirect there. Here is my access_denied. By the way, I tried
removing the format.any(:xml,:js) completely and the page just don't
react when I click on JS.
def access_denied
respond_to do |format|
format.html do
flash.now[:alert]="You need to be logged in to perform that
action."
store_location
redirect_to new_session_path
end
format.any(:xml,:js) do
request_http_basic_authentication 'Web Password'
end
end
end
Hi,
I have this annoying popup window for Web Password whenever a click on a
javascript action which require authentication. I have the problem for
FF, IE and Chrome. The problem isn't seen for non javascript action
where the user gets redirected to the html login page. Ideally, I want
even js to redirect there. Here is my access_denied. By the way, I tried
removing the format.any(:xml,:js) completely and the page just don't
react when I click on JS.
Then I guess it's because the user is not authenticated. The method is
called #access_denied, you know. Maybe you're having problems with
sessions or something similar. Do you have a #logged_in? method, and
if yes, what does it return?
Thanks rubyguy. It's expected that the user isn't logged in. Let me
summarize my problem. When the user clicks on a link_to (html) the
redirection to the login page works fine. But when the user clicks on
link_to_remote (js) the popup comes into play. Ideally i want the last
case to redirect to the login page similar to html.
The way to do this is to have your authentication code return a json response code like {status: 'not logged in'}. Then your client side JS parses that and redirects if required.
I may be wrong but I don't know of an automatic way to do this. It would require a little work.