8032-devToTest_2440 #3009

Merged
alexm merged 262 commits from 8032-devToTest_2440 into test 2024-09-24 09:34:49 +00:00
1 changed files with 29 additions and 25 deletions
Showing only changes of commit 5c3ce40bbd - Show all commits

View File

@ -49,40 +49,44 @@ module.exports = Self => {
Self.loginApp = async(ctx, user, password, deviceId, android_id, versionApp, nameApp, options) => {
const models = Self.app.models;
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
const login = await Self.app.models.VnUser.signIn(ctx, user, password, options);
await models.Account.login(ctx, user, password, myOptions);
const userId = login.user;
const userId = ctx.req.accessToken.userId;
const query =
`INSERT IGNORE INTO operator (workerFk)
VALUES (?);`;
const isUserInOperator = await models.Operator.findById(userId);
if (!isUserInOperator)
await models.Operator.create({'workerFk': userId});
const insertOperator = await Self.rawSql(query, [userId], options);
const device = await models.DeviceProduction.findById(deviceId);
const [serialNumber] = await models.DeviceProductionUser.findOne({
where: {id: '100'}
});
// const [serialNumber] = await models.DeviceProductionUser.findOne({
// where: {id: '100'}
// });
const insertDeviceLog = await models.DeviceLog.create(
{
'android_id': android_id,
'userFk': userId,
'versionApp': versionApp,
'nameApp': nameApp,
'serialNumber': [serialNumber]
},
options
);
// const insertDeviceLog = await models.DeviceLog.create(
// {
// 'android_id': android_id,
// 'userFk': userId,
// 'versionApp': versionApp,
// 'nameApp': nameApp,
// 'serialNumber': [serialNumber]
// },
// options
// );
const queryDeviceCheck =
`CALL device_checkLogin(?, ?)`;
// const queryDeviceCheck =
// `CALL device_checkLogin(?, ?)`;
const [queryDeviceCheckLogin] = await Self.rawSql(queryDeviceCheck, [userId, android_id], options);
// const [queryDeviceCheckLogin] = await Self.rawSql(queryDeviceCheck, [userId, android_id], options);
if (!queryDeviceCheckLogin.vIsAuthorized)
throw new UserError('User not authorized');
// if (!queryDeviceCheckLogin.vIsAuthorized)
// throw new UserError('User not authorized');
return insertDeviceLog;
// return insertDeviceLog;
return [];
};
};