Skip to content

Conversation

@Case-E
Copy link
Contributor

@Case-E Case-E commented Sep 10, 2025

Description

Allow users to set a session length instead of Wasp determining the default. May be even give the user the option to check a remember me box while logging in.
Need to think of all auth types,
Might be pretty standard for username/password and email but for social auth, we also need to consider that the user might need to be logged out when they log out of the provider.

Select what type of change this PR introduces:

  1. Just code/docs improvement (no functional change).
  2. Bug fix (non-breaking change which fixes an issue).
  3. New feature (non-breaking change which adds functionality).
  4. Breaking change (fix or feature that would cause existing functionality to not work as expected).

Update Waspc ChangeLog and version if needed

If you did a bug fix, new feature, or breaking change, that affects waspc, make sure you satisfy the following:

  1. I updated ChangeLog.md with description of the change this PR introduces.
  2. I bumped waspc version in waspc.cabal to reflect changes I introduced, with regards to the version of the latest wasp release, if the bump was needed.

Add a regression test if needed

If you did a bug fix, make sure you satisfy the following:

  1. I added a regression test that reproduces the bug and verifies the fix.

If you're unable to add a regression test, please explain why.
This likely indicates that our current testing setup needs improvement.

Update example apps if needed

If you did code changes and added a new feature, make sure you satisfy the following:

  1. I updated waspc/examples/todoApp and its e2e tests as needed and manually checked it works correctly.

If you did code changes and updated an existing feature, make sure you satisfy the following:

  1. I updated waspc/examples/todoApp and its e2e tests as needed and manually checked it works correctly.

Update starter apps if needed

If you did code changes and updated an existing feature, make sure you satisfy the following:

  1. I updated starter skeleton as needed and manually checked it works correctly.
  2. I updated basic starter as needed and manually checked it works correctly.
  3. I updated todo-ts starter as needed and manually checked it works correctly.
  4. I updated embeddings starter as needed and manually checked it works correctly.
  5. I updated saas starter as needed and manually checked it works correctly.

Update e2e tests if needed

If you did code changes and changed Wasp's code generation logic, make sure you satisfy the following:

  1. [] I updated e2e tests as needed and manually checked they are correct.

@Martinsos
Copy link
Member

Thanks for the PR @Case-E , we will review it soon!

@Martinsos
Copy link
Member

Related issue with the discussion: #2433 .

@infomiho
Copy link
Contributor

infomiho commented Sep 18, 2025

Hey @Case-E thank you for contributing!

I've tried running the tests locally and found some obvious issues - so it's good to have the project set up locally to be able to run ./run test to catch some of the problems right away 🙂 I'll commit my fixes for the issues I saw, but can I ask you to set up the project locally so you can run the tests locally as well? Check the README here: https://github.com/wasp-lang/wasp/tree/main/waspc

Here's my commit 964b3bc (#3144) that's added to your branch, make sure to pull the changes.

I'll review the PR now and leave any comment I might have 👍

onBeforeLogin :: Maybe ExtImport,
onAfterLogin :: Maybe ExtImport
onAfterLogin :: Maybe ExtImport,
sessionLength :: Maybe Integer
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd change the name from sessionLength to something you already have in other places - sessionExpiresInMs and I'd update all the places where this values is talked about to use the exact same name.


userEntityName = AS.refName $ AS.Auth.userEntity auth
-- Default to 30 days in milliseconds if not specified
sessionExpiresInMs = maybe (30 * 24 * 60 * 60 * 1000) (* 1000) $ AS.Auth.sessionLength auth
Copy link
Contributor

@infomiho infomiho Sep 18, 2025

Choose a reason for hiding this comment

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

In this line we implicitly defined that sessionLength is in seconds which wasn't obvious from the name. (* 1000) function told me that the value will be multiple by 1000 and then I'll get the value in ms.

I guess having sub-second session length doesn't really make any practical sense so the name might as well be sessionLengthSeconds and then we can adjust the TimeSpan to use the "s" instead of "ms" unit in lucia.ts file.

I'd probably define this like:

sessionExpiresInSeconds = fromMaybe defaultSessionDurationSeconds $ AS.Auth.sessionExpiresInSeconds auth
defaultSessionExpiresInSeconds = 30 * dayInSeconds
dayInSeconds = 24 * 60 * 60 * 1000

// sameSite: "lax",
// },
// },
sessionExpiresIn: new TimeSpan({= sessionExpiresInMs =}, "ms"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Lucia library expects a TimeSpan when defined the session length.

@Case-E
Copy link
Contributor Author

Case-E commented Sep 20, 2025

Thanks for taking a look and all the comments/work here @infomiho! This was a draft exploratory PR that I wasn't sure if I was gonna complete, however because there's not much left to do here, I'll see if I can find sometime to wrap this up over the next couple of weeks.

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.

3 participants