mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-22 14:26:07 +08:00
修复创建系统应用
This commit is contained in:
parent
fa79de3f05
commit
3f775a0e6c
|
@ -24,7 +24,7 @@ export interface AppToken {
|
|||
expiration: number;
|
||||
}
|
||||
|
||||
export type AppScope = 'envs' | 'crons' | 'configs' | 'scripts' | 'logs';
|
||||
export type AppScope = 'envs' | 'crons' | 'configs' | 'scripts' | 'logs' | 'system';
|
||||
|
||||
export interface AppInstance extends Model<App, App>, App {}
|
||||
export const AppModel = sequelize.define<AppInstance>('App', {
|
||||
|
|
|
@ -159,9 +159,17 @@ export default class OpenService {
|
|||
value: string;
|
||||
expiration: number;
|
||||
}> {
|
||||
const [systemApp] = await AppModel.findOrCreate({
|
||||
where: { name: 'system', scopes: ['crons', 'system'] },
|
||||
});
|
||||
let systemApp = (
|
||||
await AppModel.findOne({
|
||||
where: { name: 'system' },
|
||||
})
|
||||
)?.get({ plain: true });
|
||||
if (!systemApp) {
|
||||
systemApp = await this.create({
|
||||
name: 'system',
|
||||
scopes: ['crons', 'system'],
|
||||
} as App);
|
||||
}
|
||||
const { data } = await this.authToken({
|
||||
client_id: systemApp.client_id,
|
||||
client_secret: systemApp.client_secret,
|
||||
|
|
Loading…
Reference in New Issue
Block a user