diff options
Diffstat (limited to 'lib/utils.js')
| -rw-r--r-- | lib/utils.js | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/utils.js b/lib/utils.js index 2941bf9d..b4eb7ae4 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -10,6 +10,11 @@ import ln from "$lib/ln"; const { Op } = sequelize; +export const requirePin = async ({ body, user }) => { + if (user && user.pin && user.pin !== body.pin) + throw new Error("Invalid pin"); +}; + export const getUser = async (username, transaction) => { let params = { include: [ @@ -31,6 +36,8 @@ export const getUser = async (username, transaction) => { let user = await db.User.findOne(params); if (!user) throw new Error(`User ${username} not found`); + user.haspin = !!user.pin; + return user; }; |
