8032-devToTest_2440 #3009
|
@ -9,7 +9,13 @@ module.exports = Self => {
|
|||
arg: 'androidId',
|
||||
type: 'String',
|
||||
description: 'Android id'
|
||||
}, {
|
||||
},
|
||||
{
|
||||
arg: 'deviceId',
|
||||
type: 'String',
|
||||
description: 'Device id'
|
||||
},
|
||||
{
|
||||
arg: 'versionApp',
|
||||
type: 'String',
|
||||
description: 'Version app'
|
||||
|
@ -30,9 +36,10 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.handleUser = async(ctx, android_id, versionApp, nameApp, options) => {
|
||||
Self.handleUser = async(ctx, androidId, deviceId, versionApp, nameApp, options) => {
|
||||
const models = Self.app.models;
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
|
@ -41,7 +48,7 @@ module.exports = Self => {
|
|||
|
||||
const [[{vIsAuthorized, vMessage}]] =
|
||||
await Self.rawSql('CALL vn.device_checkLogin(?, ?);',
|
||||
[user.id, android_id], myOptions);
|
||||
[user.id, androidId], myOptions);
|
||||
|
||||
if (!vIsAuthorized)
|
||||
throw new UserError('Not authorized');
|
||||
|
@ -55,18 +62,17 @@ module.exports = Self => {
|
|||
if (!isUserInOperator)
|
||||
await models.Operator.create({'workerFk': user.id});
|
||||
|
||||
const serialNumber = (await models.DeviceProduction.findOne({
|
||||
where: {android_id: android_id}
|
||||
}, myOptions))?.serialNumber ?? '';
|
||||
const whereCondition = deviceId ? {id: deviceId} : {android_id: androidId};
|
||||
const serialNumber =
|
||||
(await models.DeviceProduction.findOne({where: whereCondition}, myOptions))?.serialNumber ?? '';
|
||||
|
||||
await models.DeviceLog.create({
|
||||
'android_id': android_id,
|
||||
'android_id': androidId,
|
||||
'userFk': user.id,
|
||||
'nameApp': nameApp,
|
||||
'versionApp': versionApp,
|
||||
'serialNumber': serialNumber
|
||||
}, myOptions);
|
||||
// ctx.req.accessToken = {userId};
|
||||
const getDataUser = await models.VnUser.getCurrentUserData(ctx);
|
||||
|
||||
const getDataOperator = await models.Operator.findOne({
|
||||
|
|
Loading…
Reference in New Issue