From 2d7352ed9642ceea8beb32723191eb16d56830a6 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 25 Oct 2022 13:55:28 -0700 Subject: require pin on certain endpoints --- lib/utils.js | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/utils.js') 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; }; -- cgit v1.2.3