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

Implemented user sessions #405

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

tusharad
Copy link
Contributor

@tusharad tusharad commented Dec 3, 2024

This PR introduces user session management for the Scotty, addressing the requirements outlined in issue #317. The implementation draws inspiration from the Scotty Session library.

Checklist:

  • Updated the changelog to reflect the new features.
  • Exposed the session management module via Web.Scotty.
  • Added comprehensive Haddock documentation for all public functions and types.
  • Included a practical example in the Example directory to demonstrate usage.
  • Developed test cases to ensure the robustness and reliability of the session management feature.

Dependency Update:

Added the random package to support the generation of session IDs. Please let me know if this addition is acceptable.

Do let me know if there are any further changes or additions you need. Thank you for reviewing this PR!

@ocramz

@tusharad tusharad changed the title Feature/user sessions Implemented user sessions Dec 3, 2024
@ocramz ocramz self-assigned this Dec 4, 2024
@ocramz
Copy link
Collaborator

ocramz commented Dec 4, 2024

@tusharad Thank you! I think this is a very good PR. Just couple of minor remarks on documentation and a return type.

@ocramz
Copy link
Collaborator

ocramz commented Dec 31, 2024

Hi @tusharad , hope you're doing well! I was wondering whether you need any help to land this PR? Please let us know :)

@tusharad
Copy link
Contributor Author

Hi @ocramz,

I believe there might have been a misunderstanding. Since you self-assigned this task, I assumed you would be implementing some of the changes yourself.

"Just a couple of minor remarks on documentation and a return type."

Could you please elaborate on the specific return type and areas in the documentation you’d like to see revised? This will help me address your feedback more effectively.

Thanks!

@ocramz ocramz removed their assignment Dec 31, 2024
@ocramz
Copy link
Collaborator

ocramz commented Dec 31, 2024

Hi @tusharad , yes apologies about that!

The return type I was mentioning is that of getUserSession, to distinguish the "no session" case from "expired". But I'm open to keeping this as it is with a strong enough argument :)

@tusharad
Copy link
Contributor Author

tusharad commented Dec 31, 2024

Hi @ocramz,

Thank you for the feedback! In the latest update, I’ve replaced Nothing with Either and introduced a new type called SessionStatus, which can represent SessionExpired or SessionNotFound. Please let me know if there’s anything else you’d like to adjust or further refine. I appreciate your input!

@ocramz ocramz self-requested a review January 4, 2025 01:15
Copy link
Collaborator

@ocramz ocramz left a comment

Choose a reason for hiding this comment

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

A few outstanding comments, but mainly:

  • missing ActionM specialized Session functions
  • changelog entry with issue number
  • Session module header with correct authors and copyright

Optional but nice to have :

  • add a mention of the new Session functionality in the README

Web/Scotty/Session.hs Outdated Show resolved Hide resolved
threadDelay 1000000
maintainSessions sessionJar

-- | Adds a new session to the session jar.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Adds or overwrites, that is

Web/Scotty/Session.hs Show resolved Hide resolved
changelog.md Outdated
@@ -1,5 +1,6 @@
## next [????.??.??]

* Added sessions.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you please refer to the github issue number here?

Web/Scotty.hs Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

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

As far as I can see, this file (Web.Scotty) is missing the specialized versions of the Session functions, returning in the ActionM monad. See e.g. https://hackage.haskell.org/package/scotty-0.22/docs/src/Web.Scotty.html#request

@tusharad
Copy link
Contributor Author

tusharad commented Jan 4, 2025

Thanks for the review @ocramz!

  • Added ActionM specialized Session functions. I noticed the cookie functions don't have ActionM versions—should I open a separate issue for this?
  • Updated changelog entry with issue number
  • Updated session module header with correct authors and copyright.
  • I missed mentioning sessions in README :(
  • I also squeezed in optional expiration time as argument in createUsersSession.

Do let me know in anything else is required. Thanks again!

@ocramz
Copy link
Collaborator

ocramz commented Jan 4, 2025

@tusharad Thanks for the revision!

the cookie functions don't have ActionM versions—should I open a separate issue for this?

Yes please, open a new ticket for this.

@ocramz
Copy link
Collaborator

ocramz commented Jan 4, 2025

@tusharad thanks! There's still time to add a line to the README, in the Examples section :)

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.

2 participants