diff --git a/server/db/db.js b/server/db/db.js index 51a315d..61f12ca 100644 --- a/server/db/db.js +++ b/server/db/db.js @@ -185,12 +185,12 @@ async function insertUser(username, passwordHash) { async function getUserId(username) { const query = ` SELECT user_id, username AS dbUsername FROM Accounts - WHERE LOWER(username) = $1; + WHERE LOWER(username) = LOWER($1); `; try { const result = await client.query(query, [username]); if (result.rows.length > 0) { - return result.rows[0]; + return result.rows[0].user_id; } else { console.log("No user found with username: ", username); return null; @@ -321,7 +321,7 @@ async function addMemberToGroupByUsername(conversation_id, username) { WITH user_id_query AS ( SELECT user_id FROM Accounts - WHERE LOWER(username) = $1 + WHERE LOWER(username) = LOWER($1) LIMIT 1 ), insert_membership AS ( @@ -466,7 +466,7 @@ async function changePassword(username, newPasswordHash) { const query = ` UPDATE Accounts SET password_hash = $1 - WHERE username = $2; + WHERE LOWER(username) = LOWER($2); `; try { await client.query(query, [newPasswordHash, username]);