Compare commits
1 Commits
static-can
...
static-can
Author | SHA1 | Date | |
---|---|---|---|
![]() |
62b656add1 |
@@ -0,0 +1,11 @@
|
||||
export async function up(knex) {
|
||||
await knex.schema.table('app_configs', (table) => {
|
||||
table.boolean('can_custom_connect').defaultTo(false);
|
||||
});
|
||||
}
|
||||
|
||||
export async function down(knex) {
|
||||
await knex.schema.table('app_configs', (table) => {
|
||||
table.dropColumn('can_custom_connect');
|
||||
});
|
||||
}
|
@@ -62,7 +62,7 @@ class AppAuthClient extends Base {
|
||||
|
||||
async assignCanConnectForAppConfig() {
|
||||
const appConfig = await AppConfig.query().findOne({ key: this.appKey });
|
||||
await appConfig?.assignCanConnect();
|
||||
await appConfig?.$query()?.patch({});
|
||||
}
|
||||
|
||||
async $afterInsert(queryContext) {
|
||||
|
@@ -16,6 +16,7 @@ class AppConfig extends Base {
|
||||
shared: { type: 'boolean', default: false },
|
||||
disabled: { type: 'boolean', default: false },
|
||||
canConnect: { type: 'boolean', default: false },
|
||||
canCustomConnect: { type: 'boolean', default: false },
|
||||
},
|
||||
};
|
||||
|
||||
@@ -48,14 +49,21 @@ class AppConfig extends Base {
|
||||
this.canConnect = canConnect;
|
||||
}
|
||||
|
||||
async assignCanCustomConnect() {
|
||||
const canCustomConnect = !this.disabled && this.allowCustomConnection;
|
||||
this.canCustomConnect = canCustomConnect;
|
||||
}
|
||||
|
||||
async $beforeInsert(queryContext) {
|
||||
await super.$beforeInsert(queryContext);
|
||||
await this.assignCanConnect();
|
||||
await this.assignCanCustomConnect();
|
||||
}
|
||||
|
||||
async $beforeUpdate(opt, queryContext) {
|
||||
await super.$beforeUpdate(opt, queryContext);
|
||||
await this.assignCanConnect();
|
||||
await this.assignCanCustomConnect();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user