feat: save last auth attempt per customer

This commit is contained in:
Rafael Taranto 2024-05-29 09:24:18 +01:00
parent 5ae9b76c3b
commit 4743f7f62c
5 changed files with 34 additions and 8 deletions

View file

@ -23,6 +23,7 @@ const T = require('../time')
const plugins = require('../plugins')
const Tx = require('../tx')
const loyalty = require('../loyalty')
const logger = require('../logger')
function updateCustomerCustomInfoRequest (customerId, patch, req, res) {
if (_.isNil(patch.data)) {
@ -203,6 +204,12 @@ function addOrUpdateCustomer (customerData, config, isEmailAuth) {
return addFunction(customerData)
})
.then(customer => customers.getById(customer.id))
.then(customer => {
customers.updateLastAuthAttempt(customer.id).catch(() => {
logger.info('failure updating last auth attempt for customer ', customer.id)
})
return customer
})
.then(customer => {
return Tx.customerHistory(customer.id, maxDaysThreshold)
.then(result => {