I have a popup that will allow viewing / saving of some information if the user is authenticated.
I am using the app.
In the before_filter controller, it checks if the user has been signed, and if not, display the page with the signature.
This page on page resets the version of the site login page so that it fits well in the pop-up window.
In the authentication action, I call authenticate_user !. Everything works fine when the user enters valid credentials. But when the credentials are invalid, automatically redirect to the site login page (which, as I said, is different and not suitable for the pop-up window)
I tried to add salvation to the challenge, but to no avail.
Can anyone suggest a better / correct way to do this, please? :)
def authenticate authenticate_user! rescue redirect_to "/popup/sign_in" if user_signed_in? respond_to do |format| format.html { flash[:notice] = I18n.t("logged_in_succesfully") redirect_back_or_default(accounts_path) } else flash[:error] = I18n.t("devise.failure.invalid") render "/popup/sign_in" end end
source share