chore: undo $ prepend on queries
This commit is contained in:
parent
f3f2bb01b0
commit
ba4117173e
50 changed files with 215 additions and 227 deletions
|
|
@ -7,7 +7,7 @@ function generateOTP (name) {
|
|||
|
||||
const sql = 'insert into one_time_passes (token, name) values ($1, $2)'
|
||||
|
||||
return db.$none(sql, [otp, name])
|
||||
return db.none(sql, [otp, name])
|
||||
.then(() => otp)
|
||||
}
|
||||
|
||||
|
|
@ -16,7 +16,7 @@ function validateOTP (otp) {
|
|||
where token=$1
|
||||
returning name, created < now() - interval '1 hour' as expired`
|
||||
|
||||
return db.$one(sql, [otp])
|
||||
return db.one(sql, [otp])
|
||||
.then(r => ({success: !r.expired, expired: r.expired, name: r.name}))
|
||||
.catch(() => ({success: false, expired: false}))
|
||||
}
|
||||
|
|
@ -29,7 +29,7 @@ function register (otp) {
|
|||
const token = crypto.randomBytes(32).toString('hex')
|
||||
const sql = 'insert into user_tokens (token, name) values ($1, $2)'
|
||||
|
||||
return db.$none(sql, [token, r.name])
|
||||
return db.none(sql, [token, r.name])
|
||||
.then(() => ({success: true, token: token}))
|
||||
})
|
||||
.catch(() => ({success: false, expired: false}))
|
||||
|
|
@ -38,7 +38,7 @@ function register (otp) {
|
|||
function authenticate (token) {
|
||||
const sql = 'select token from user_tokens where token=$1'
|
||||
|
||||
return db.$one(sql, [token]).then(() => true).catch(() => false)
|
||||
return db.one(sql, [token]).then(() => true).catch(() => false)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue