From 8266d3adad8d093212b208ff93e6bee41f3370e3 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 6 Jan 2023 13:59:03 -0800 Subject: locktime field, uuid for token --- lib/passport.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'lib/passport.js') diff --git a/lib/passport.js b/lib/passport.js index ac2949a5..1244aab5 100644 --- a/lib/passport.js +++ b/lib/passport.js @@ -35,13 +35,19 @@ fastifyPassport.use( }, async (payload, next) => { try { - let { username } = payload; + let { username, uuid } = payload; + let where = {}; + + if (username) + where.username = { [Op.or]: [username, username.replace(/ /g, "")] }; + + if (uuid) where.uuid = uuid; + let user = await db.User.findOne({ - where: { - username: { [Op.or]: [username, username.replace(/ /g, "")] } - }, + where, include: { model: db.Account, as: "account" } }); + if (user.locked) throw new Error("account is locked"); next(null, user); } catch (e) { -- cgit v1.2.3