SessionService
SessionService
Contains methods relating to Session entities.
class SessionService implements EntitySubscriberInterface, OnApplicationBootstrap {
constructor(connection: TransactionalConnection, configService: ConfigService, orderService: OrderService, jobQueueService: JobQueueService, requestContextService: RequestContextService)
onApplicationBootstrap() => ;
createNewAuthenticatedSession(ctx: RequestContext, user: User, authenticationStrategyName: string) => Promise<AuthenticatedSession>;
createAnonymousSession() => Promise<CachedSession>;
getSessionFromToken(sessionToken: string) => Promise<CachedSession | undefined>;
serializeSession(session: AuthenticatedSession | AnonymousSession) => CachedSession;
setActiveOrder(ctx: RequestContext, serializedSession: CachedSession, order: Order) => Promise<CachedSession>;
unsetActiveOrder(ctx: RequestContext, serializedSession: CachedSession) => Promise<CachedSession>;
setActiveChannel(serializedSession: CachedSession, channel: Channel) => Promise<CachedSession>;
deleteSessionsByUser(ctx: RequestContext, user: User) => Promise<void>;
deleteSessionsByActiveOrderId(ctx: RequestContext, activeOrderId: ID) => Promise<void>;
triggerCleanSessionsJob(batchSize: number) => ;
cleanExpiredSessions(ctx: RequestContext, batchSize: number) => ;
}
- Implements:
EntitySubscriberInterface
,OnApplicationBootstrap
constructor
(connection: TransactionalConnection, configService: ConfigService, orderService: OrderService, jobQueueService: JobQueueService, requestContextService: RequestContextService) => SessionService
onApplicationBootstrap
() =>
createNewAuthenticatedSession
(ctx: RequestContext, user: User, authenticationStrategyName: string) => Promise<AuthenticatedSession>
Creates a new AuthenticatedSession. To be used after successful authentication.
createAnonymousSession
() => Promise<CachedSession>
Create an AnonymousSession and caches it using the configured SessionCacheStrategy, and returns the cached session object.
getSessionFromToken
(sessionToken: string) => Promise<CachedSession | undefined>
Returns the cached session object matching the given session token.
serializeSession
(session: AuthenticatedSession | AnonymousSession) => CachedSession
Serializes a Session instance into a simplified plain object suitable for caching.
setActiveOrder
(ctx: RequestContext, serializedSession: CachedSession, order: Order) => Promise<CachedSession>
Sets the activeOrder
on the given cached session object and updates the cache.
unsetActiveOrder
(ctx: RequestContext, serializedSession: CachedSession) => Promise<CachedSession>
Clears the activeOrder
on the given cached session object and updates the cache.
setActiveChannel
(serializedSession: CachedSession, channel: Channel) => Promise<CachedSession>
Sets the activeChannel
on the given cached session object and updates the cache.
deleteSessionsByUser
(ctx: RequestContext, user: User) => Promise<void>
Deletes all existing sessions for the given user.
deleteSessionsByActiveOrderId
(ctx: RequestContext, activeOrderId: ID) => Promise<void>
Deletes all existing sessions with the given activeOrder.
triggerCleanSessionsJob
(batchSize: number) =>
Triggers the clean sessions job.
cleanExpiredSessions
(ctx: RequestContext, batchSize: number) =>
Cleans expired sessions from the database & the session cache.