remove sync
This commit is contained in:
@@ -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);
|
||||||
});
|
// });
|
||||||
|
|||||||
@@ -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');
|
||||||
|
|||||||
@@ -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);
|
||||||
});
|
// });
|
||||||
|
|||||||
@@ -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);
|
||||||
});
|
// });
|
||||||
|
|||||||
@@ -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);
|
||||||
});
|
// });
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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);
|
||||||
});
|
// });
|
||||||
|
|||||||
@@ -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);
|
||||||
});
|
// });
|
||||||
|
|||||||
@@ -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);
|
||||||
});
|
// });
|
||||||
|
|||||||
@@ -53,37 +53,35 @@ 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;
|
||||||
let payload: any = {};
|
if (sign) {
|
||||||
try {
|
let payload: any = {};
|
||||||
payload = jsonwebtoken.verify(loginToken, tokenSecret);
|
try {
|
||||||
} catch (e) {
|
payload = jsonwebtoken.verify(loginToken, tokenSecret);
|
||||||
await setErrorLoginTokenRedis(loginToken);
|
} catch (e) {
|
||||||
ctx.throw(400, 'loginToken error');
|
await setErrorLoginTokenRedis(loginToken);
|
||||||
}
|
ctx.throw(400, 'loginToken error');
|
||||||
const { timestamp } = payload;
|
}
|
||||||
|
const { timestamp } = payload;
|
||||||
|
|
||||||
const checkSign = MD5(`${tokenSecret}${timestamp}`).toString();
|
const checkSign = MD5(`${tokenSecret}${timestamp}`).toString();
|
||||||
if (sign !== checkSign) {
|
if (sign !== checkSign) {
|
||||||
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);
|
||||||
|
|||||||
Reference in New Issue
Block a user