Merge pull request #1694 from siiky/feat/lam-1111/customer-last-used-machine

LAM-1111 View last-used machine name on customer profile
This commit is contained in:
Rafael Taranto 2024-08-05 13:44:28 +01:00 committed by GitHub
commit 6274bccde5
8 changed files with 39 additions and 17 deletions

View file

@ -257,7 +257,7 @@ function getExternalComplianceLink (req, res, next) {
.then(url => respond(req, res, { url }))
}
function addOrUpdateCustomer (customerData, config, isEmailAuth) {
function addOrUpdateCustomer (customerData, deviceId, config, isEmailAuth) {
const triggers = configManager.getTriggers(config)
const maxDaysThreshold = complianceTriggers.maxDaysThreshold(triggers)
@ -273,7 +273,7 @@ function addOrUpdateCustomer (customerData, config, isEmailAuth) {
})
.then(customer => customers.getById(customer.id))
.then(customer => {
customers.updateLastAuthAttempt(customer.id).catch(() => {
customers.updateLastAuthAttempt(customer.id, deviceId).catch(() => {
logger.info('failure updating last auth attempt for customer ', customer.id)
})
return customer
@ -292,14 +292,15 @@ function addOrUpdateCustomer (customerData, config, isEmailAuth) {
}
function getOrAddCustomerPhone (req, res, next) {
const deviceId = req.deviceId
const customerData = req.body
const pi = plugins(req.settings, req.deviceId)
const pi = plugins(req.settings, deviceId)
const phone = req.body.phone
return pi.getPhoneCode(phone)
.then(code => {
return addOrUpdateCustomer(customerData, req.settings.config, false)
return addOrUpdateCustomer(customerData, deviceId, req.settings.config, false)
.then(customer => respond(req, res, { code, customer }))
})
.catch(err => {