Merge pull request #902 from chaotixkilla/fix-machine-pairing-on-non-tejos
Fix machine pairing on older machine versions
This commit is contained in:
commit
2e1564c23c
1 changed files with 5 additions and 1 deletions
|
|
@ -5,6 +5,10 @@ const db = require('./db')
|
|||
const options = require('./options')
|
||||
const logger = require('./logger')
|
||||
|
||||
// A machine on an older version (no multicassette code) could be paired with a server with multicassette code.
|
||||
// This makes sure that the server stores a default value
|
||||
const DEFAULT_NUMBER_OF_CASSETTES = 2
|
||||
|
||||
function pullToken (token) {
|
||||
const sql = `delete from pairing_tokens
|
||||
where token=$1
|
||||
|
|
@ -20,7 +24,7 @@ function unpair (deviceId) {
|
|||
return Promise.all([db.none(sql, [deviceId]), db.none(deleteMachinePings, [deviceId])])
|
||||
}
|
||||
|
||||
function pair (token, deviceId, machineModel, numOfCassettes) {
|
||||
function pair (token, deviceId, machineModel, numOfCassettes = DEFAULT_NUMBER_OF_CASSETTES) {
|
||||
return pullToken(token)
|
||||
.then(r => {
|
||||
if (r.expired) return false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue