fix: Pass app config parameters to be used for hooks

This commit is contained in:
Faruk AYDIN
2024-10-25 01:07:44 +02:00
parent 240854e4ac
commit 91c9ef3068
2 changed files with 5 additions and 9 deletions

View File

@@ -66,6 +66,8 @@ class AppAuthClient extends Base {
// This is a workaround to update connection allowed column for AppConfig
await appConfig?.$query().patch({
key: appConfig.key,
shared: appConfig.shared,
disabled: appConfig.disabled,
});
}

View File

@@ -47,21 +47,15 @@ class AppConfig extends Base {
}
async computeConnectionAllowedProperty() {
const refetchedRecord = await AppConfig.query().findOne({ key: this.key });
if (!refetchedRecord) return;
const appAuthClients = await refetchedRecord.$relatedQuery(
'appAuthClients'
);
const appAuthClients = await this.$relatedQuery('appAuthClients');
const hasSomeActiveAppAuthClients =
appAuthClients?.some((appAuthClient) => appAuthClient.active) || false;
const conditions = [
hasSomeActiveAppAuthClients,
refetchedRecord.shared,
!refetchedRecord.disabled,
this.shared,
!this.disabled,
];
const connectionAllowed = conditions.every(Boolean);