Annoying pop up window with restful_authentication

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

Thanks,

On 10 Mar., 05:41, Youyou S. [email protected]
wrote:

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

request_http_basic_authentication ‘Web Password’

end

The #request_http_basic_authentication method prompts the user for a
password. Maybe that is the “popup” you’re talking about.

[email protected] wrote:

On 10 Mar., 05:41, Youyou S. [email protected]
wrote:

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

� � � � � request_http_basic_authentication ‘Web Password’

� � end

The #request_http_basic_authentication method prompts the user for a
password. Maybe that is the “popup” you’re talking about.

Yes I confirm that it is. When I remove it. Nothing happens when you
click on a link_to_remote (js)

On 10 Mar., 14:21, Youyou S. [email protected]
wrote:

[email protected] wrote:

The #request_http_basic_authentication method prompts the user for a
password. Maybe that is the “popup” you’re talking about.

Yes I confirm that it is. When I remove it. Nothing happens when you
click on a link_to_remote (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.

SH

Starr H.
My blog: http://starrhorne.com
Check out my Helpdesk RailsKit: http://railskits.com/helpdesk/

[email protected] wrote:

On 10 Mar., 14:21, Youyou S. [email protected]
wrote:

[email protected] wrote:

The #request_http_basic_authentication method prompts the user for a
password. Maybe that is the “popup” you’re talking about.

Yes I confirm that it is. When I remove it. Nothing happens when you
click on a link_to_remote (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.

Thanks,

Starr H. wrote:

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.

SH

Starr H.
My blog: http://starrhorne.com
Check out my Helpdesk RailsKit: http://railskits.com/helpdesk/

Thanks Starr. Can you please tell me how to do the json status? Is it
something, that I put in the access_denied method? Should I just add
this: {status: ‘not logged in’}?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs