Sign in user after confimation success#1282
Conversation
Signing in the user automatically after confirming was removed from Devise for a good reason!
Not sure if thats the reason here, but in Devise, you can Configure a "Trial" Periode in which the user can be logged in (for a certain amount of time) before he has to confirm the User. In this case, a user would be already logged in at this point in time, so the check does make sense |
|
@iv-mexx thanks for your comment. I get the reasons why we shouldn't do it. I was trying to sign in the user there for callbacks to be executed but the thing is that we actually already have a signed_in user. Let me explain it: While digging into the code, I found that after the This actually happens because What I think that we can do here is use local variable instead of instance variable ( What do you think? |
|
|
||
| if signed_in?(resource_name) | ||
| client_id, token = signed_in_resource.create_token | ||
| client_id, token = @resource.create_token |
There was a problem hiding this comment.
Remove this as http://blog.plataformatec.com.br/2013/08/devise-3-1-now-with-more-secure-defaults/, we weren't doing anything with the tokens previously, so it doesn't make sense to create new tokens here.
|
@GAKINDUSTRIES Good work! but I don't understand this "I still think that we should remove the logged_in option" |
|
@MaicolBen why hasn't this merged? |

• Issue: #1278
• Topic: Bug: Registration broken if multiple users signed in
Digging into the code while trying to tackle this issue, I found a few more:
signed_in?helper: This helper checks if a user object is signed in. We should useuser_signed_in?instead.confirmation_tokenandredirect_url, there's no way that a user is logged at this point (considering that we are not using cookies to keep the session)I attach the code of
create_tokenmethod:Thus, we create the user with a token that can't be used later. We need to save the generated token (
@resource.save!) to reflect the new token at the database level.In this PR I removed the logged in conditional and I log in the user (using
store: falseto avoid saving in session) andsave!the record to update it in the database. I also reorder the methods inside the controller (to keep CRUD order) and fix a small indentation problem.Note: I removed the test within
unauthenticated contextsince it does not make sense anymore.