Identify machine name on logging upon clock skew error (#188)

This commit is contained in:
pedromiguelmiranda 2018-10-13 16:12:12 +01:00 committed by Josh Harvey
parent 85295ea62c
commit 7a07412a70
2 changed files with 13 additions and 4 deletions

View file

@ -299,7 +299,8 @@ function filterOldRequests (req, res, next) {
const delta = Date.now() - Date.parse(deviceTime)
if (delta > CLOCK_SKEW) {
logger.error('Clock skew with lamassu-machine too high [%ss], adjust lamassu-machine clock', (delta / 1000).toFixed(2))
logger.error('Clock skew with lamassu-machine[%s] too high [%ss], adjust lamassu-machine clock',
req.deviceName, (delta / 1000).toFixed(2))
}
if (delta > REQUEST_TTL) return res.status(408).json({error: 'stale'})
@ -311,8 +312,9 @@ function authorize (req, res, next) {
return pairing.isPaired(deviceId)
.then(r => {
if (r) {
if (r.isDevicePaired) {
req.deviceId = deviceId
req.deviceName = r.deviceName
return next()
}