heartcombo / devise

Flexible authentication solution for Rails with Warden.
http://blog.plataformatec.com.br/tag/devise/
MIT License
24.01k stars 5.55k forks source link

Devise's return status on the login page does not match what is expected, thus not rendering the error message correctly in frontend #5713

Closed ubuygold closed 2 months ago

ubuygold commented 2 months ago

Environment

The default Devise configuration, no custom content, uses rails g devise:views to generate view files to use the simple_form and bootstrap styles.

On the current login page localhost:3000/users/sign_in, when a form error occurs, it is not possible to display the error using bootstrap styling (Simple_form should be able to handle these errors automatically and then display them using bootstrap styling).Errors are only displayed in <p><%= alert %></p>.

login

And in the registration page localhost:3000/users_sign_up it can be displayed normally in bootstrap style.

signup

Meanwhile, on the login page, as you can see through browser debugging, it returns a 422 error status. login_inspect

And in the backend output of rails, it returns a 401 error and immediately renders back a new sign_in without returning an error, could this be the cause of the above problem?

login_output

signup, returns the message only once and is accompanied by a 422 status code. signup_output

Expected behavior

The Login page returns the 422 status code normally, as does the sign_up page, and errors are correctly caught and rendered by simple_form.