-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
no redirect after sign_in #4742
Comments
@TheScarfix Can you provide a sample app which reproduces this behavior? I've bootstrapped a simple app with the same versions and haven't been able to reproduce yet. |
@nynhex created a new application and it works as intended, any ideas how to find the error in my app? |
Having the same issue as @TheScarfix - upgraded to 4.4.0 to use Ruby 2.5.0 and app no longer redirects after a login, stays on sign_in path even though the user is now signed in. Refreshing the page at this point redirects you correctly to the It seems that in If I just apply the Ruby 2.5.0 fix #4668 to Devise 4.3.0 it works OK. I'm using Devise inside an engine.
Env: Rails 5.1.4 Ruby 2.5.0 Devise 4.4.0 |
I'm going to take a look at this. |
I'm having the same problem, Ruby 2.5.0, Rails 5.1.4, Devise 4.4.0. Using 1009096 works as intended. Tried to review commits after this one to find the problem, but with no luck. |
I've done some debugging, and I guess that this commit is causing this. |
@tegon Well spotted and thank you, yes that seems to be the issue in our case. I should have thought to check that. In |
@woodpigeon Thank you for confirming this. We could do some check inside the |
@tegon I've confirmed that password is empty and |
@tegon can confirm that resource is invalid and resource.errors says the password can't be blank |
@ryuzee @TheScarfix did you override the |
@tegon no, but I had validation for :password in the User model, deleted it and now it does redirect |
@tegon I've confirmed that the model is invalid. My bad, not devise 🤦♂️ |
I'm closing this since we'll keep the running the validations in the https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-4.4.0 Feel free to contribute with your solutions. This may be helpful to others in the future. Thanks! |
This feels a bit like changing the contract; as far as I'm aware, Devise never previously required the resource to be valid during authentication.
If there was previously an implicit assumption that the resource would be valid, that has now been made explicit by the change to In our application, we've now got: def active_for_authentication?
invalid? ? false : super
end
def inactive_message
invalid? ? :record_invalid : super
end ...I wonder if something like this shouldn't be added to the default behaviour in |
I agree with @joshpencheon that this feels like a substantial change to the contract of sign-in. In an old product whose validation rules have changed over time, it's reasonable to have legacy users who were valid at signup but are now invalid. Before 4.4.0 these users could still sign in to fix their accounts! If invalid users can't sign in, any new validation which accidentally impacts a portion of the existing userbase becomes an immediate showstopper, rather than only applying to new signups. |
@joshpencheon @gmcnaughton This wasn't an implicit assumption, it worked before without any validations until we found a problem with this approach. |
Thanks @tegon, I appreciate you taking the time! 😄 I'm concerned about two issues: legacy accounts and future changes.
|
@gmcnaughton They seem to be the same issue, actually. Do you have any examples of this? |
This is still broken! https://stackoverflow.com/questions/48913707/devise-after-sign-in-path-for-not-working-being-ignored Devise should not validate upon sign in! If you had some problem before, then you should validate when REGISTERING/CREATING a user, but not when SIGNING IN / UPDATING a user. That renders Consider using #update_attribute or #update_columns instead to set the I'm going to have to downgrade to 4.3. |
Another quick fix could be to override While that issue enforces to have a valid record on sign_in, it is a bit weird behaviour because as @starrychloe mentioned it does create a session and does not update the record. Also when you refresh you are redirected to the correct path instead of being stuck sign_in like when the session is created. Side note: What made my record invalid is that for Rails 5 belongs_to :association, optional: true Your record will be invalid and |
We already removed the validations on #4796, I'll release a version soon. |
Environment
Current behavior
no redirect after sign_in
Expected behavior
redirect to after_sign_in_path (screenshot taken with the same environment except devise 4.3.0 instead of 4.4.0)
The text was updated successfully, but these errors were encountered: