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

Link user to the sessions create to enable lookup of all sessions by user #20477

Closed
wants to merge 1 commit into from

Conversation

gtanzillo
Copy link
Member

@gtanzillo gtanzillo commented Aug 24, 2020

Prototype for using the sessions table to link a user to open sessions.

This change creates a has_many link between the users and sessions tables. The approach creates the link after a user successfully authenticates, at which point the user instance and the request containing the session id are available. The nice thing about this approach is that is should work regardless of the configured session store because it doesn’t rely on the session data being present in the sessions table (as it would be for ActiveRecord::SessionStore)

Depends on schema PR: TBD

Fixes: #20476

@gtanzillo gtanzillo marked this pull request as draft August 24, 2020 19:11
@gtanzillo
Copy link
Member Author

/cc @Fryguy @jvlcek

end

def link_user_to_session(request)
session_id = request.session_options[:id]
Copy link
Member

Choose a reason for hiding this comment

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

Does the code need to account for request being nil?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it should 👍

@miq-bot
Copy link
Member

miq-bot commented Aug 24, 2020

Checked commit gtanzillo@fa3c8ee with ruby 2.6.3, rubocop 0.69.0, haml-lint 0.28.0, and yamllint
1 file checked, 1 offense detected

app/models/user.rb

@Fryguy
Copy link
Member

Fryguy commented Sep 23, 2020

schema changes were merged, as was #20549

@miq-bot
Copy link
Member

miq-bot commented Oct 9, 2020

This pull request is not mergeable. Please rebase and repush.

@Fryguy
Copy link
Member

Fryguy commented Oct 12, 2020

Closing in favor of #20601

@Fryguy Fryguy closed this Oct 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Link user to session ids to enable looking up the session ids of every session a user owns
4 participants