remove sync

This commit is contained in:
2025-12-28 16:16:23 +08:00
parent 9f51d27398
commit df6db9d88b
10 changed files with 42 additions and 53 deletions

View File

@@ -66,6 +66,6 @@ AppDemoModel.init(
}, },
); );
AppDemoModel.sync({ alter: true, logging: false }).catch((e) => { // AppDemoModel.sync({ alter: true, logging: false }).catch((e) => {
console.error('AppDemoModel sync', e); // console.error('AppDemoModel sync', e);
}); // });

View File

@@ -4,22 +4,13 @@ import { OrgInit } from '../auth/models/index.ts';
export { User, UserInit, UserServices, UserSecret }; export { User, UserInit, UserServices, UserSecret };
import { useContextKey } from '@kevisual/context'; import { useContextKey } from '@kevisual/context';
const init = async () => { const init = async () => {
await OrgInit(null, null, { await OrgInit(null, null).catch((e) => {
alter: true,
logging: false,
}).catch((e) => {
console.error('Org sync', e); console.error('Org sync', e);
}); });
await UserInit(null, null, { await UserInit(null, null).catch((e) => {
alter: true,
logging: false,
}).catch((e) => {
console.error('User sync', e); console.error('User sync', e);
}); });
await UserSecretInit(null, null, { await UserSecretInit(null, null).catch((e) => {
alter: true,
logging: false,
}).catch((e) => {
console.error('UserSecret sync', e); console.error('UserSecret sync', e);
}); });
console.log('Models synced'); console.log('Models synced');

View File

@@ -82,6 +82,6 @@ AppDomainModel.init(
}, },
); );
AppDomainModel.sync({ alter: true, logging: false }).catch((e) => { // AppDomainModel.sync({ alter: true, logging: false }).catch((e) => {
console.error('AppDomainModel sync', e); // console.error('AppDomainModel sync', e);
}); // });

View File

@@ -51,6 +51,6 @@ AppListModel.init(
}, },
); );
AppListModel.sync({ alter: true, logging: false }).catch((e) => { // AppListModel.sync({ alter: true, logging: false }).catch((e) => {
console.error('AppListModel sync', e); // console.error('AppListModel sync', e);
}); // });

View File

@@ -155,6 +155,6 @@ AppModel.init(
}, },
); );
AppModel.sync({ alter: true, logging: false }).catch((e) => { // AppModel.sync({ alter: true, logging: false }).catch((e) => {
console.error('AppModel sync', e); // console.error('AppModel sync', e);
}); // });

View File

@@ -142,8 +142,8 @@ ConfigModel.init(
}, },
); );
ConfigModel.sync({ alter: true, logging: false }).catch((e) => { // ConfigModel.sync({ alter: true, logging: false }).catch((e) => {
console.error('ConfigModel sync', e); // console.error('ConfigModel sync', e);
}); // });
useContextKey('ConfigModel', () => ConfigModel); useContextKey('ConfigModel', () => ConfigModel);

View File

@@ -96,6 +96,6 @@ ContainerModel.init(
}, },
); );
ContainerModel.sync({ alter: true, logging: false }).catch((e) => { // ContainerModel.sync({ alter: true, logging: false }).catch((e) => {
console.error('ContainerModel sync', e); // console.error('ContainerModel sync', e);
}); // });

View File

@@ -40,6 +40,6 @@ GithubModel.init(
}, },
); );
GithubModel.sync({ alter: true, logging: false }).catch((e) => { // GithubModel.sync({ alter: true, logging: false }).catch((e) => {
console.error('GithubModel sync', e); // console.error('GithubModel sync', e);
}); // });

View File

@@ -83,6 +83,6 @@ PageModel.init(
}, },
); );
PageModel.sync({ alter: true, logging: false }).catch((e) => { // PageModel.sync({ alter: true, logging: false }).catch((e) => {
console.error('PageModel sync', e); // console.error('PageModel sync', e);
}); // });

View File

@@ -53,23 +53,19 @@ app
await setErrorLoginTokenRedis(loginToken); await setErrorLoginTokenRedis(loginToken);
ctx.throw(400, 'token is expired and redirect error'); ctx.throw(400, 'token is expired and redirect error');
} }
return; return;
} }
if (!loginToken) { if (!loginToken) {
await setErrorLoginTokenRedis(loginToken); await setErrorLoginTokenRedis(loginToken);
ctx.throw(400, 'loginToken is required'); ctx.throw(400, 'loginToken is required');
} }
if (!sign) {
await setErrorLoginTokenRedis(loginToken);
ctx.throw(400, 'sign is required');
}
if (!randomId) { if (!randomId) {
await setErrorLoginTokenRedis(loginToken); await setErrorLoginTokenRedis(loginToken);
ctx.throw(400, 'randomId is required'); ctx.throw(400, 'randomId is required');
} }
const tokenSecret = 'xiao' + randomId; const tokenSecret = 'xiao' + randomId;
if (sign) {
let payload: any = {}; let payload: any = {};
try { try {
payload = jsonwebtoken.verify(loginToken, tokenSecret); payload = jsonwebtoken.verify(loginToken, tokenSecret);
@@ -84,6 +80,8 @@ app
await setErrorLoginTokenRedis(loginToken); await setErrorLoginTokenRedis(loginToken);
ctx.throw(400, 'sign error'); ctx.throw(400, 'sign error');
} }
}
const user = await User.findByPk(tokenUser.id); const user = await User.findByPk(tokenUser.id);
if (!user) { if (!user) {
await setErrorLoginTokenRedis(loginToken); await setErrorLoginTokenRedis(loginToken);