feat: update the customer's last_used_machine on auth attempt
This commit is contained in:
parent
bb303a38cf
commit
53830aba52
2 changed files with 8 additions and 7 deletions
|
|
@ -930,9 +930,9 @@ function disableTestCustomer (customerId) {
|
||||||
return db.none(sql, [customerId])
|
return db.none(sql, [customerId])
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateLastAuthAttempt (customerId) {
|
function updateLastAuthAttempt (customerId, deviceId) {
|
||||||
const sql = `UPDATE customers SET last_auth_attempt=NOW() WHERE id=$1`
|
const sql = `UPDATE customers SET last_auth_attempt=NOW(), last_used_machine=$2 WHERE id=$1`
|
||||||
return db.none(sql, [customerId])
|
return db.none(sql, [customerId, deviceId])
|
||||||
}
|
}
|
||||||
|
|
||||||
function getExternalComplianceMachine (customer) {
|
function getExternalComplianceMachine (customer) {
|
||||||
|
|
|
||||||
|
|
@ -257,7 +257,7 @@ function getExternalComplianceLink (req, res, next) {
|
||||||
.then(url => respond(req, res, { url }))
|
.then(url => respond(req, res, { url }))
|
||||||
}
|
}
|
||||||
|
|
||||||
function addOrUpdateCustomer (customerData, config, isEmailAuth) {
|
function addOrUpdateCustomer (customerData, deviceId, config, isEmailAuth) {
|
||||||
const triggers = configManager.getTriggers(config)
|
const triggers = configManager.getTriggers(config)
|
||||||
const maxDaysThreshold = complianceTriggers.maxDaysThreshold(triggers)
|
const maxDaysThreshold = complianceTriggers.maxDaysThreshold(triggers)
|
||||||
|
|
||||||
|
|
@ -273,7 +273,7 @@ function addOrUpdateCustomer (customerData, config, isEmailAuth) {
|
||||||
})
|
})
|
||||||
.then(customer => customers.getById(customer.id))
|
.then(customer => customers.getById(customer.id))
|
||||||
.then(customer => {
|
.then(customer => {
|
||||||
customers.updateLastAuthAttempt(customer.id).catch(() => {
|
customers.updateLastAuthAttempt(customer.id, deviceId).catch(() => {
|
||||||
logger.info('failure updating last auth attempt for customer ', customer.id)
|
logger.info('failure updating last auth attempt for customer ', customer.id)
|
||||||
})
|
})
|
||||||
return customer
|
return customer
|
||||||
|
|
@ -292,14 +292,15 @@ function addOrUpdateCustomer (customerData, config, isEmailAuth) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getOrAddCustomerPhone (req, res, next) {
|
function getOrAddCustomerPhone (req, res, next) {
|
||||||
|
const deviceId = req.deviceId
|
||||||
const customerData = req.body
|
const customerData = req.body
|
||||||
|
|
||||||
const pi = plugins(req.settings, req.deviceId)
|
const pi = plugins(req.settings, deviceId)
|
||||||
const phone = req.body.phone
|
const phone = req.body.phone
|
||||||
|
|
||||||
return pi.getPhoneCode(phone)
|
return pi.getPhoneCode(phone)
|
||||||
.then(code => {
|
.then(code => {
|
||||||
return addOrUpdateCustomer(customerData, req.settings.config, false)
|
return addOrUpdateCustomer(customerData, deviceId, req.settings.config, false)
|
||||||
.then(customer => respond(req, res, { code, customer }))
|
.then(customer => respond(req, res, { code, customer }))
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue