Skip to content

add user_id field in session table #72

Open
@mo

Description

@mo

When a user does a password reset / changes his password, it makes sense to drop all sessions for that user. Currently the user id is stored inside a json blob on the session, so it becomes very inefficient to query for all sessions that belong to a specific user.

In issue #53 ( #53 ), it was suggested that one way to workaround this issue is to, A) not use createDatabaseTable: true, B) add a user_id column, and C) right after login, update the session with the appropriate user_id.

However, this approach has the downside that "user_id" cannot be a "NOT NULL" column with a foreign key constraint pointing to the user table. This in turn would enable cascading deletes for sessions when a user is deleted.

      columnNames: {
        user_id: 'user_id',
        ...
     }

Do you agree that having such a column is a good idea, i.e. would you accept a PR to add one?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions