Skip to content
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

Fix/session timeout #304

Conversation

PedroAugustoRamalhoDuarte

Please ensure your pull request includes the following:

  • Description of changes
  • Update to CHANGELOG.md with short description and link to pull request
  • Changes have related RSpec tests that ensure functionality does not break

Description

When :remember_me, :session_timeout module are on, the user is not logged out when the first session ends, because session_timeout invalidate the session and remember_me module creates another after that. With this problem we cant logged out a user with timeout when remember_me is on

Solution

Forget remember me token in session_timeout

closes #303

@joshbuker
Copy link
Member

Sorry for the slow response times, been slammed/stressed lately. Haven't forgotten about this, but haven't had the mental bandwidth to tackle it either. Will hopefully get this fixed and tackle the other open issues in the near future, once I'm caught up on other things.

@PedroAugustoRamalhoDuarte
Copy link
Author

Hello @joshbuker, would you mind checking this issue again?

@joshbuker
Copy link
Member

10 months... Yikes, my bad.

Yeah, adding this to my priority task list.

Copy link
Member

@joshbuker joshbuker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears the second test is incorrectly labeled. Can you update it to "remember_me functions before session timeout" or similar, assuming that matches your intention?

expect(session[:user_id]).to be_nil
end

it 'does not resets session and remember_me cookies after session timeout' do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this test supposed to be "does not reset session and remember_me cookies before session timeout"?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, i will change

@joshbuker
Copy link
Member

Thanks for your patience ❤️

Depressingly, even my priority task list is hilariously backlogged.

@PedroAugustoRamalhoDuarte
Copy link
Author

Thank you for the review, I will improve this specs next week and test a little bit more. This line Timecop.travel(Time.now.in_time_zone + 0.6) looks like magic, i will try to explicit setup the session timeout for make the specs easier to read

@@ -52,6 +52,7 @@ def register_login_time(_user, _credentials = nil)
def validate_session
session_to_use = Config.session_timeout_from_last_action ? session[:last_action_time] : session[:login_time]
if (session_to_use && sorcery_session_expired?(session_to_use.to_time)) || sorcery_session_invalidated?
forget_me! if current_user.present? && Config.submodules.include?(:remember_me)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it make more sense to just call logout here?
There might be other before/after logout hooks configured and logout already takes care of calling all of those.
Just discovered this PR after I ran into the same problem and opened my PR with logout here:
#358

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @jankoegel i saw you PR, yes is better then mine. Makes more sense to call logout. Can i add the tests in your PR?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I invited you as a collaborator to my fork. Let me know if that works for you & thanks for preparing the specs!

@PedroAugustoRamalhoDuarte
Copy link
Author

@joshbuker @jankoegel closing to resolve in #358

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Session timeout module does not logout user
3 participants