const db = require("../models");
const API = require('../helper/API_Response');
const db_helper = require("../helper/db_helper");
const helper = require("../helper/helper");
const { User, Version, Navigation, Onbording } = require("../models");

exports.by = async (req, res) => {
  const input = await helper.decryptRequest(req.body.data);
  res.status(200).send(API._200(await db_helper.selectByWhere('LoginLogs', input, ['id', 'user_id', 'createdAt', 'updatedAt'])));
};
exports.add = async (req, res) => {
  const input = await helper.decryptRequest(req.body.data);
  input.ipaddress = req.ip;
  input.browser = req.headers['user-agent'];
  await db.sequelize.query("update users set is_live=1 where id= :user_id", { replacements: { user_id: input.user_id } })
  res.status(200).send(API._200(await db_helper.addData('LoginLogs', input)));
};
