Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Centralize logic on getting the current session id #88

Merged
merged 1 commit into from
Jan 28, 2021

Conversation

paulomarg
Copy link
Contributor

WHY are these changes introduced?

The previous implementation of deleteCurrentSession essentially replicated a previous iteration of loadCurrentSession, which caused errors due to them being out of sync.

WHAT is this pull request doing?

Extracted the logic to obtain the current session id from the request into a shared method, that is now called from both loadCurrentSession and deleteCurrentSession, so they should always behave consistently.

Type of change

  • Patch: Bug (non-breaking change which fixes an issue)
  • Minor: New feature (non-breaking change which adds functionality)
  • Major: Breaking change (fix or feature that would cause existing functionality to not work as expected)

@paulomarg paulomarg requested a review from a team as a code owner January 27, 2021 20:29
@paulomarg paulomarg force-pushed the refactor_delete_current_session branch from 6da677d to 0233f84 Compare January 27, 2021 20:33
* @param request HTTP request object
* @param response HTTP response object
*/
getCurrentSessionId(request: http.IncomingMessage, response: http.ServerResponse): string | undefined {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if it really makes sense for these functions (getOfflineSessionId and getCurrentSessionId) to live inside of OAuth class. Should we move them to somewhere within src/auth/session?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was actually torn about that myself. What made me keep them here (for now) was the fact that the OAuth function is basically what determines what session ids we use for which scenarios (offline vs online, embedded or not). But then again, they are all more deeply connected to Sessions than they are to OAuth, so I can see this going either way.

): Promise<boolean | never> {
Context.throwIfUninitialized();

if (Context.IS_EMBEDDED_APP) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I love all of these deleted lines 😍

@paulomarg paulomarg force-pushed the refactor_delete_current_session branch from 0233f84 to ea183a3 Compare January 27, 2021 21:19
@paulomarg paulomarg merged commit b8c7717 into main Jan 28, 2021
@paulomarg paulomarg deleted the refactor_delete_current_session branch January 28, 2021 13:52
@paulomarg paulomarg temporarily deployed to production February 3, 2021 16:01 Inactive
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants