nodebil v2
This commit is contained in:
@@ -185,12 +185,12 @@ async function insertUser(username, passwordHash) {
|
|||||||
async function getUserId(username) {
|
async function getUserId(username) {
|
||||||
const query = `
|
const query = `
|
||||||
SELECT user_id, username AS dbUsername FROM Accounts
|
SELECT user_id, username AS dbUsername FROM Accounts
|
||||||
WHERE LOWER(username) = $1;
|
WHERE LOWER(username) = LOWER($1);
|
||||||
`;
|
`;
|
||||||
try {
|
try {
|
||||||
const result = await client.query(query, [username]);
|
const result = await client.query(query, [username]);
|
||||||
if (result.rows.length > 0) {
|
if (result.rows.length > 0) {
|
||||||
return result.rows[0];
|
return result.rows[0].user_id;
|
||||||
} else {
|
} else {
|
||||||
console.log("No user found with username: ", username);
|
console.log("No user found with username: ", username);
|
||||||
return null;
|
return null;
|
||||||
@@ -321,7 +321,7 @@ async function addMemberToGroupByUsername(conversation_id, username) {
|
|||||||
WITH user_id_query AS (
|
WITH user_id_query AS (
|
||||||
SELECT user_id
|
SELECT user_id
|
||||||
FROM Accounts
|
FROM Accounts
|
||||||
WHERE LOWER(username) = $1
|
WHERE LOWER(username) = LOWER($1)
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
),
|
),
|
||||||
insert_membership AS (
|
insert_membership AS (
|
||||||
@@ -466,7 +466,7 @@ async function changePassword(username, newPasswordHash) {
|
|||||||
const query = `
|
const query = `
|
||||||
UPDATE Accounts
|
UPDATE Accounts
|
||||||
SET password_hash = $1
|
SET password_hash = $1
|
||||||
WHERE username = $2;
|
WHERE LOWER(username) = LOWER($2);
|
||||||
`;
|
`;
|
||||||
try {
|
try {
|
||||||
await client.query(query, [newPasswordHash, username]);
|
await client.query(query, [newPasswordHash, username]);
|
||||||
|
|||||||
Reference in New Issue
Block a user