refs #6434 perf: use rawSql instead query
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Javier Segarra 2023-11-17 11:24:12 +01:00
parent a3076e4fa1
commit a7be577e92
1 changed files with 1 additions and 6 deletions

View File

@ -126,12 +126,7 @@ module.exports = function (Self) {
}); });
Self.signInValidate = async (user, userToken, token, ctx) => { Self.signInValidate = async (user, userToken, token, ctx) => {
const [[key, value]] = Object.entries(Self.userUses(user)); const [[key, value]] = Object.entries(Self.userUses(user));
const where = Self.userUses(user); const isOwner = Self.rawSql(`SELECT ? = ? `, [userToken[key], value]);
const vnUser = await Self.findOne({
fields: ['id', 'username', 'email'],
where
});
const isOwner = userToken[key].toLowerCase() === vnUser[key].toLowerCase();
await Self.app.models.SignInLog.create({ await Self.app.models.SignInLog.create({
token: token.id, token: token.id,
userFk: userToken.id, userFk: userToken.id,