is it possible to render a modal dialog box from the server?

I have a before filter that authorizes a user's credentials before giving them access to any protected methods (pretty standard practice). If they fail authorization, I want to direct them to a chance to login or to create an account (also pretty standard practice).

Here's the rub: I want to offer them a login form in a small modal box overlayed on their current screen. I know how to do this from the client side, using javascript, but in this case, I want the server to render that modal box (since it's the server that determines that the user's credentials are missing).

Any ideas how to do this?

Thanks, Yoram

The server can only respond to client (browser) requests, so you have to either render a login page and then redirect to the original destination or you need to have some javascript to help with what you want. In short, the server can't MAKE the browser do anything...

so you have

to either render a login page

yes but - can i render that login page as an overlay modal box instead of a full page? i suspect that the answer is not...

thanks for your reply

yoram wrote: [...]

yes but - can i render that login page as an overlay modal box instead of a full page?

[...]

Sure, with appropriate JavaScript and a suitably constructed partial or other HTML file. (But remember to make it accessible also to users who don't have JavaScript turned on.)

Also see if HTTP-Basic authentication is suitable for your needs. With this model, the server tells the browser that it wants login credentials, and the browser presents a login dialog of some sort, so that the server doesn't have to provide an HTML login form.

Best,

Check out Craig Ambrose's Redbox plugin.

HTH, Bill