Skip to content

Commit

Permalink
fix(core): Fix bug where session user in cache would get removed
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbromley committed Jul 16, 2020
1 parent fa5caf5 commit ebec0f0
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions packages/core/src/service/services/session.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ export class SessionService implements EntitySubscriberInterface {
}

async setActiveOrder(serializedSession: CachedSession, order: Order): Promise<CachedSession> {
const session = await this.connection.getRepository(Session).findOne(serializedSession.id);
const session = await this.connection
.getRepository(Session)
.findOne(serializedSession.id, { relations: ['user', 'user.roles', 'user.roles.channels'] });
if (session) {
session.activeOrder = order;
await this.connection.getRepository(Session).save(session, { reload: false });
Expand All @@ -182,10 +184,14 @@ export class SessionService implements EntitySubscriberInterface {
if (serializedSession.activeOrderId) {
const session = await this.connection
.getRepository(Session)
.save({ id: serializedSession.id, activeOrder: null });
const updatedSerializedSession = this.serializeSession(session);
await this.configService.authOptions.sessionCacheStrategy.set(updatedSerializedSession);
return updatedSerializedSession;
.findOne(serializedSession.id, { relations: ['user', 'user.roles', 'user.roles.channels'] });
if (session) {
session.activeOrder = null;
await this.connection.getRepository(Session).save(session);
const updatedSerializedSession = this.serializeSession(session);
await this.configService.authOptions.sessionCacheStrategy.set(updatedSerializedSession);
return updatedSerializedSession;
}
}
return serializedSession;
}
Expand Down

0 comments on commit ebec0f0

Please sign in to comment.