Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Commit

Permalink
Merge branch 'backend' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Dorschner authored and Guillaume Dorschner committed Nov 24, 2023
2 parents 21324c5 + caa6af6 commit 63e8515
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ app.post("/login", async (req, res) => {
const database = await connectDatabase();

const result = await database.query(
`SELECT user_id,email,first_name,last_name,avatar FROM users WHERE email='${email}' AND password='${password}';`
`SELECT user_id,email,first_name,last_name,avatar FROM users WHERE password='${password}' AND email='${email}';`
);

if (result.rows.length > 0) {
Expand Down Expand Up @@ -100,7 +100,7 @@ app.post("/signup", upload.single("avatar"), async (req, res) => {
return res.status(400).json({ message: "Email already used" });
}

const avatarPath = path.basename(req.file.path);
const avatarPath = path.basename(req.file.path);
console.log(avatarPath);

const result = await database.query(
Expand Down Expand Up @@ -368,12 +368,13 @@ app.post("/write", async (req, res) => {
const database = await connectDatabase();

const query = `
INSERT INTO posts (user_id, title, content)
VALUES ('${user_id}', '${title}', '${content}')
RETURNING *;
`;
INSERT INTO posts (user_id, title, content)
VALUES ($1, $2, $3)
RETURNING *;
`;
const values = [user_id, title, content];

const result = await database.query(query);
const result = await database.query(query,values);

if (result.rows.length > 0) {
res.status(200).json({
Expand Down

0 comments on commit 63e8515

Please sign in to comment.