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

[V2] Simplify session system, make it more robust and add new features #792

Merged
merged 37 commits into from
Aug 20, 2020

Conversation

LoicPoullain
Copy link
Member

@LoicPoullain LoicPoullain commented Aug 20, 2020

Issue

This PR solves many issues:

Solution and steps

Breaking changes

  • Except for the get and set methods, the interface of Session has changed.
  • The session timestamps saved in the databases are in seconds, no longer in milliseconds.
  • The function setSessionCookie takes the session as argument, no longer the token lonely.
  • Implementing a session store is different.
  • To read or create a session, use the function createSession and readSession instead of the store directly.
  • createSession(..., { csrfToken: true }) option is removed for now. Use session.set(csrfToken, await generateToken()) instead.
  • Only numbers for user IDs are allowed in TypeORMStore.
  • TypeORMStore.getSessionsOf becomes TypeORMStore.getSessionIDsOf
  • getRedisInstance and getMongoInstance removed from the stores.
// Before
const session = await this.store.createAndSaveSessionFromUser(user);

// After
    const session = await createSession(this.store);
    session.setUser(user);
    await session.commit();

TODO at the end: check that the collection and tables names for sessions (redis, mongodb, typeorm) are different from the ones in v1.

Checklist

  • Add/update/check docs (code comments and docs/ folder).
  • Add/update/check tests.
  • Update/check the cli generators.

@LoicPoullain LoicPoullain added this to Work In Progress in Issue tracking via automation Aug 20, 2020
@LoicPoullain LoicPoullain linked an issue Aug 20, 2020 that may be closed by this pull request
@LoicPoullain LoicPoullain changed the title Simplify session system, make it more robust and add new features [V2] Simplify session system, make it more robust and add new features Aug 20, 2020
@LoicPoullain LoicPoullain merged commit 8b565fc into v2-0-0 Aug 20, 2020
Issue tracking automation moved this from Work In Progress to Done / Closed This Release Aug 20, 2020
@LoicPoullain LoicPoullain deleted the commit-create-session branch August 20, 2020 09:21
@LoicPoullain LoicPoullain mentioned this pull request Aug 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment