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 // This is a workaround to update connection allowed column for AppConfig
await appConfig?.$query().patch({ await appConfig?.$query().patch({
key: appConfig.key, key: appConfig.key,
shared: appConfig.shared,
disabled: appConfig.disabled,
}); });
} }

View File

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