diff --git a/backendV2/routes/admin/database/userDataMgmt.database.js b/backendV2/routes/admin/database/userDataMgmt.database.js index f9a58a2..9f92893 100644 --- a/backendV2/routes/admin/database/userDataMgmt.database.js +++ b/backendV2/routes/admin/database/userDataMgmt.database.js @@ -36,7 +36,7 @@ export const deleteUserById = async (userId) => { export const changePassword = async (userId, newPassword) => { const [result] = await pool.query( - "UPDATE users SET password = ? WHERE id = ?", + "UPDATE users SET password = ?, entry_updated_at = NOW() WHERE id = ?", [newPassword, userId] ); if (result.affectedRows > 0) return { success: true }; @@ -52,7 +52,7 @@ export const editUserById = async ( is_admin ) => { const [result] = await pool.query( - "UPDATE users SET first_name = ?, last_name = ?, role = ?, email = ?, is_admin = ? WHERE id = ?", + "UPDATE users SET first_name = ?, last_name = ?, role = ?, email = ?, is_admin = ?, entry_updated_at = NOW() WHERE id = ?", [first_name, last_name, role, email, is_admin, userId] ); if (result.affectedRows > 0) return { success: true }; diff --git a/backendV2/services/database.js b/backendV2/services/database.js index 6a09279..5cb8875 100644 --- a/backendV2/services/database.js +++ b/backendV2/services/database.js @@ -17,7 +17,15 @@ export const verifyAPIKeyDB = async (apiKey) => { [apiKey] ); if (result.length > 0) { - return { valid: true }; + const [lastUsed] = await pool.query( + "UPDATE apiKeys SET last_used_at = NOW() WHERE api_key = ?;", + [apiKey] + ); + if (lastUsed.affectedRows > 0) { + return { valid: true }; + } else { + return { valid: false }; + } } else { return { valid: false }; }