aboutsummaryrefslogtreecommitdiffstats
path: root/lib/utils.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2022-10-25 13:55:28 -0700
committerAdam Soltys <[email protected]>2022-10-25 13:55:32 -0700
commit2d7352ed9642ceea8beb32723191eb16d56830a6 (patch)
tree0aef2e7bd3d82144708ee62f4d4a2f599f620db2 /lib/utils.js
parent6128d0ef6cd994807e6b30420be0874f1a8e94ef (diff)
downloadcoinos-server-2d7352ed9642ceea8beb32723191eb16d56830a6.tar.gz
coinos-server-2d7352ed9642ceea8beb32723191eb16d56830a6.zip
require pin on certain endpoints
Diffstat (limited to 'lib/utils.js')
-rw-r--r--lib/utils.js7
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;
};