Fix exception on clock skew (#202)
* Fix exception on clock skew * Return device name instead of db object
This commit is contained in:
parent
a35cb5c78d
commit
bd75194526
2 changed files with 4 additions and 11 deletions
|
|
@ -74,14 +74,7 @@ function isPaired (deviceId) {
|
|||
const sql = 'select device_id, name from devices where device_id=$1 and paired=TRUE'
|
||||
|
||||
return db.oneOrNone(sql, [deviceId])
|
||||
.then(row => {
|
||||
const deviceName = row.name
|
||||
const isDevicePaired = row && row.device_id === deviceId
|
||||
return {
|
||||
deviceName: deviceName,
|
||||
isDevicePaired: isDevicePaired
|
||||
}
|
||||
})
|
||||
.then(row => row && row.device_id === deviceId ? row.name : false)
|
||||
}
|
||||
|
||||
module.exports = {pair, unpair, authorizeCaDownload, isPaired}
|
||||
|
|
|
|||
|
|
@ -311,10 +311,10 @@ function authorize (req, res, next) {
|
|||
const deviceId = req.deviceId
|
||||
|
||||
return pairing.isPaired(deviceId)
|
||||
.then(r => {
|
||||
if (r.isDevicePaired) {
|
||||
.then(deviceName => {
|
||||
if (deviceName) {
|
||||
req.deviceId = deviceId
|
||||
req.deviceName = r.deviceName
|
||||
req.deviceName = deviceName
|
||||
return next()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue