Chore: merge compliance notification code changes

This commit is contained in:
csrapr 2021-03-17 17:04:01 +00:00 committed by Josh Harvey
parent fc39d9b1a3
commit 757db75d1a
7 changed files with 36 additions and 21 deletions

View file

@ -10,6 +10,7 @@ const customers = require('../customers')
const httpError = require('../route-helpers').httpError
const plugins = require('../plugins')
const Tx = require('../tx')
const respond = require('../respond')
function addOrUpdateCustomer (req) {
const customerData = req.body
@ -52,7 +53,7 @@ function getCustomerWithPhoneCode (req, res, next) {
return pi.getPhoneCode(phone)
.then(code => {
return addOrUpdateCustomer(req)
.then(customer => res.status(200).json({ code, customer }))
.then(customer => respond(req, res, { code, customer }))
})
.catch(err => {
if (err.name === 'BadNumberError') throw httpError('Bad number', 401)