I have a very simple sign_in page for a developer. When sending incorrect data, the log shows "401 Unauthorized" and redirects me back to the sign_in page. I could not understand how to display error messages to the user.
I looked at devise::sessions_controller#createthat which looks like this:
def create
resource = warden.authenticate!(auth_options)
set_flash_message(:notice, :signed_in) if is_navigational_format?
sign_in(resource_name, resource)
respond_with resource, :location => after_sign_in_path_for(resource)
end
def auth_options
{ :scope => resource_name, :recall => "#{controller_path}#new" }
end
The flow is interrupted when warden.authenticateauthentication fails and the user is redirected to "new", which is the sign_in page.
I just need to show the user the hint invalid_credentials / flash_message. So I did this by changing when authentication fails, within which I set error messages.:recall => "#{controller_path}#handle_create_fail" (look at auth_options), handle_create_fails
I am not sure that I have missed what has already been developed.
?