-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Sign in user after confimation success #1282
base: master
Are you sure you want to change the base?
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? |
@@ -11,39 +25,21 @@ def show | |||
|
|||
redirect_header_options = { account_confirmation_success: true } | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_token
andredirect_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_token
method: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: false
to 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 context
since it does not make sense anymore.