MongoSessions
Implements
- unknown
Index
Constructors
constructor
Parameters
options: MongoSessionsOptions
Returns MongoSessions
Methods
publiccreateSession
Parameters
userId: string
User id of the session.
token: string
Random token used to identify the session.
connection: ConnectionInformations = {}
Connection informations related to the session (such as user agent, ip etc..).
optionalextraData: object
Any extra data you would like to add. The data will be added to the root of the object.
Returns Promise<string>
publicfindSessionById
Get a session by his id.
Parameters
sessionId: string
Id used to query the session.
Returns Promise<any>
publicfindSessionByToken
Get a session by his token.
Parameters
token: string
Token used to query the session.
Returns Promise<any>
publicinvalidateAllSessions
Invalidate all the session of a user.
Parameters
userId: string
User id of the sessions.
optionalexcludedSessionIds: string[]
Can be used to whitelist some sessions. Eg: close all the sessions except these ones.
Returns Promise<void>
publicinvalidateSession
Invalidate a session.
Parameters
sessionId: string
Id of the session to invalidate.
Returns Promise<void>
publicsetupIndexes
Setup the mongo indexes needed for the sessions.
Parameters
options: Omit<CreateIndexesOptions, unique | sparse> = {}
Options passed to the mongo native
createIndex
method.
Returns Promise<void>
publicupdateSession
Update the session informations, token and connection informations.
Parameters
sessionId: string
Id used to update the session.
connection: ConnectionInformations
Connection informations related to the session (such as user agent, ip etc..).
optionalnewToken: string
New token that will replace the existing token for the session.
Returns Promise<void>
Create a new session attached to a user.