From a7be577e92e295f653f186a53f95d42ac64e5ef0 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 17 Nov 2023 11:24:12 +0100 Subject: [PATCH] refs #6434 perf: use rawSql instead query --- back/models/vn-user.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/back/models/vn-user.js b/back/models/vn-user.js index c7fe3012f..e000aa4c7 100644 --- a/back/models/vn-user.js +++ b/back/models/vn-user.js @@ -126,12 +126,7 @@ module.exports = function (Self) { }); Self.signInValidate = async (user, userToken, token, ctx) => { const [[key, value]] = Object.entries(Self.userUses(user)); - const where = Self.userUses(user); - const vnUser = await Self.findOne({ - fields: ['id', 'username', 'email'], - where - }); - const isOwner = userToken[key].toLowerCase() === vnUser[key].toLowerCase(); + const isOwner = Self.rawSql(`SELECT ? = ? `, [userToken[key], value]); await Self.app.models.SignInLog.create({ token: token.id, userFk: userToken.id,