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

Astro sessions "regenerate" currently non functional #12863

Closed
1 task done
kaytwo opened this issue Dec 30, 2024 · 0 comments · Fixed by #12864
Closed
1 task done

Astro sessions "regenerate" currently non functional #12863

kaytwo opened this issue Dec 30, 2024 · 0 comments · Fixed by #12864
Labels
needs triage Issue needs to be triaged

Comments

@kaytwo
Copy link
Contributor

kaytwo commented Dec 30, 2024

Astro Info

Astro                    v5.1.1
Node                     v22.12.0
System                   macOS (arm64)
Package Manager          npm
Output                   static
Adapter                  @astrojs/node
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

Session regeneration is currently non functional - the current code deletes the #sessionID property to indicate that the existing session id is deleted:

this.#sessionID = undefined;

But then it uses #ensureSessionID() to generate a new one, which doesn't check that private property, but instead checks the cookie directly:

this.#sessionID ??= this.#cookies.get(this.#cookieName)?.value ?? crypto.randomUUID();

If a session exists, this check will always succeed, leading to the session ID not changing.

I believe this is fixable by removing the call to #ensureSessionID and replacing this line:

this.#sessionID = undefined;

with a direct regeneration, i.e. this.#sessionID = crypto.randomUUID();

What's the expected result?

The session id should change.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-muwk6ati-gxwf5xkb?file=src%2Fpages%2Findex.astro

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Issue needs to be triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant