Skip to content

Commit

Permalink
fix: reset oauth instance when app url changed
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <[email protected]>
  • Loading branch information
Innei committed Dec 3, 2024
1 parent 635e27d commit 54d9021
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions apps/core/src/constants/event-bus.constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export enum EventBusEvents {
SystemException = 'system.exception',
ConfigChanged = 'config.changed',
OauthChanged = 'oauth.changed',
AppUrlChanged = 'app.url.changed',
}
2 changes: 2 additions & 0 deletions apps/core/src/modules/auth/auth.middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ export class AuthMiddleware implements NestMiddleware, OnModuleInit {
this.authInstance.set(auth)
}
this.redisSub.subscribe(EventBusEvents.OauthChanged, handler)
this.redisSub.subscribe(EventBusEvents.AppUrlChanged, handler)

await handler()
}

Expand Down
5 changes: 5 additions & 0 deletions apps/core/src/modules/configs/configs.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ export class ConfigsService {
encryptObject(instanceValue)

switch (key) {
case 'url': {
const newValue = await this.patch(key, instanceValue)
this.subpub.publish(EventBusEvents.AppUrlChanged, newValue)
return newValue
}
case 'mailOptions': {
const option = await this.patch(key as 'mailOptions', instanceValue)
if (option.enable) {
Expand Down

0 comments on commit 54d9021

Please sign in to comment.