Merge pull request #1683 from RafaelTaranto/feat/save-last-auth-attempt-customer

LAM-1108 feat: save last auth attempt per customer
This commit is contained in:
Rafael Taranto 2024-06-05 08:21:11 +01:00 committed by GitHub
commit 35d38e0dee
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 => {