fix: Do not create oauth clients for non-supported apps
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import App from './app.js';
|
||||
import OAuthClient from './oauth-client.js';
|
||||
import Base from './base.js';
|
||||
import { ValidationError } from 'objection';
|
||||
|
||||
class AppConfig extends Base {
|
||||
static tableName = 'app_configs';
|
||||
@@ -39,6 +40,27 @@ class AppConfig extends Base {
|
||||
|
||||
return await App.findOneByKey(this.key);
|
||||
}
|
||||
|
||||
async createOAuthClient(params) {
|
||||
const supportsOauthClients = (await this.getApp())?.auth?.generateAuthUrl
|
||||
? true
|
||||
: false;
|
||||
|
||||
if (!supportsOauthClients) {
|
||||
throw new ValidationError({
|
||||
data: {
|
||||
app: [
|
||||
{
|
||||
message: 'This app does not support OAuth clients!',
|
||||
},
|
||||
],
|
||||
},
|
||||
type: 'ModelValidation',
|
||||
});
|
||||
}
|
||||
|
||||
return await this.$relatedQuery('oauthClients').insert(params);
|
||||
}
|
||||
}
|
||||
|
||||
export default AppConfig;
|
||||
|
||||
Reference in New Issue
Block a user