Browse Source

fix(auth): transition users only when transition mode enabled

Karol Sójko 1 year ago
parent
commit
610fba2601

+ 1 - 0
packages/auth/src/Bootstrap/Container.ts

@@ -981,6 +981,7 @@ export class ContainerConfigLoader {
           container.get(TYPES.Auth_GenerateRecoveryCodes),
           container.get(TYPES.Auth_Logger),
           container.get(TYPES.Auth_SessionService),
+          container.get(TYPES.Auth_TRANSITION_MODE_ENABLED),
         ),
       )
     container

+ 8 - 5
packages/auth/src/Controller/AuthController.ts

@@ -37,6 +37,7 @@ export class AuthController implements UserServerInterface {
     private doGenerateRecoveryCodes: GenerateRecoveryCodes,
     private logger: Logger,
     private sessionService: SessionServiceInterface,
+    private transitionModeEnabled: boolean,
   ) {}
 
   async update(_params: UserUpdateRequestParams): Promise<HttpResponse<UserUpdateResponse>> {
@@ -227,11 +228,13 @@ export class AuthController implements UserServerInterface {
     if (userUuid !== null) {
       headers = new Map([['x-invalidate-cache', userUuid]])
 
-      await this.domainEventPublisher.publish(
-        this.domainEventFactory.createTransitionRequestedEvent({
-          userUuid,
-        }),
-      )
+      if (this.transitionModeEnabled) {
+        await this.domainEventPublisher.publish(
+          this.domainEventFactory.createTransitionRequestedEvent({
+            userUuid,
+          }),
+        )
+      }
     }
 
     return {