feat: customer auth via email
This commit is contained in:
parent
92a3f16c80
commit
ab304093f3
22 changed files with 252 additions and 27 deletions
|
|
@ -45,12 +45,12 @@ function toCashOutTx (row) {
|
|||
return _.set('direction', 'cashOut', newObj)
|
||||
}
|
||||
|
||||
function fetchPhoneTx (phone) {
|
||||
function fetchEmailOrPhoneTx (data, type) {
|
||||
const sql = `select * from cash_out_txs
|
||||
where phone=$1 and dispense=$2
|
||||
where ${type === 'email' ? 'email' : 'phone'}=$1 and dispense=$2
|
||||
and (extract(epoch from (now() - created))) * 1000 < $3`
|
||||
|
||||
const values = [phone, false, TRANSACTION_EXPIRATION]
|
||||
const values = [data, false, TRANSACTION_EXPIRATION]
|
||||
|
||||
return db.any(sql, values)
|
||||
.then(_.map(toCashOutTx))
|
||||
|
|
@ -72,6 +72,13 @@ function fetchPhoneTx (phone) {
|
|||
throw httpError('No transactions', 404)
|
||||
})
|
||||
}
|
||||
function fetchEmailTx (email) {
|
||||
return fetchEmailOrPhoneTx(email, 'email')
|
||||
}
|
||||
|
||||
function fetchPhoneTx (phone) {
|
||||
return fetchEmailOrPhoneTx(phone, 'phone')
|
||||
}
|
||||
|
||||
function fetchStatusTx (txId, status) {
|
||||
const sql = 'select * from cash_out_txs where id=$1'
|
||||
|
|
@ -88,6 +95,7 @@ function fetchStatusTx (txId, status) {
|
|||
module.exports = {
|
||||
stateChange,
|
||||
fetchPhoneTx,
|
||||
fetchEmailTx,
|
||||
fetchStatusTx,
|
||||
httpError
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue