Fix change_username

This commit is contained in:
KernelDeimos
2024-04-03 22:06:06 -04:00
parent b7a1f21e31
commit b055c5cdad

View File

@@ -59,7 +59,11 @@ module.exports = eggspress('/change_username', {
// Has the user already changed their username twice this month?
const rows = await db.read(
'SELECT COUNT(*) AS `count` FROM `user_update_audit` ' +
'WHERE `user_id`=? AND `reason`=? AND `created_at` > DATE_SUB(NOW(), INTERVAL 1 MONTH)',
'WHERE `user_id`=? AND `reason`=? AND ' +
db.case({
mysql: '`created_at` > DATE_SUB(NOW(), INTERVAL 1 MONTH)',
sqlite: "`created_at` > datetime('now', '-1 month')",
}),
[ req.user.id, 'change_username' ]
);