Merge branch 'v5' of github.com:lamassu/lamassu-server into origin-v5
This commit is contained in:
commit
c860df1576
3 changed files with 56 additions and 2 deletions
|
|
@ -16,6 +16,7 @@ const helpers = require('./route-helpers')
|
|||
const poller = require('./poller')
|
||||
const Tx = require('./tx')
|
||||
const E = require('./error')
|
||||
const customers = require('./customers')
|
||||
|
||||
const argv = require('minimist')(process.argv.slice(2))
|
||||
|
||||
|
|
@ -143,6 +144,24 @@ function verifyTx (req, res, next) {
|
|||
.catch(next)
|
||||
}
|
||||
|
||||
function getCustomerWithPhoneCode (req, res, next) {
|
||||
const pi = plugins(req.settings, req.deviceId)
|
||||
const phone = req.body.phone
|
||||
return pi.getPhoneCode(phone)
|
||||
.then(code => {
|
||||
return customers.get(phone.phone).then(customer => {
|
||||
if (customer) return respond(req, res, {code, customer})
|
||||
return customers.add(req.body)
|
||||
.then(customer => respond(req, res, {code, customer}))
|
||||
})
|
||||
})
|
||||
.catch(err => {
|
||||
if (err.name === 'BadNumberError') throw httpError('Bad number', 410)
|
||||
throw err
|
||||
})
|
||||
.catch(next)
|
||||
}
|
||||
|
||||
function ca (req, res) {
|
||||
const token = req.query.token
|
||||
|
||||
|
|
@ -269,7 +288,7 @@ app.post('/event', deviceEvent)
|
|||
app.post('/verify_user', verifyUser)
|
||||
app.post('/verify_transaction', verifyTx)
|
||||
|
||||
app.post('/phone_code', phoneCode)
|
||||
app.post('/phone_code', getCustomerWithPhoneCode)
|
||||
app.post('/tx', postTx)
|
||||
app.get('/tx/:id', getTx)
|
||||
app.get('/tx', getPhoneTx)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue