Browse Source

WIP profile update

features/create-channel
Astri4-4 5 months ago
parent
commit
c039db6f98
  1. 16
      backend/app/controllers/user.controller.js
  2. BIN
      backend/app/uploads/profiles/astri6.jpg
  3. BIN
      backend/app/uploads/profiles/astri7.jpg
  4. BIN
      backend/app/uploads/profiles/astria2.jpg
  5. BIN
      backend/app/uploads/profiles/astria3.jpg
  6. 98
      backend/logs/access.log

16
backend/app/controllers/user.controller.js

@ -184,8 +184,22 @@ export async function update(req, res) {
user.password = userInBase.password; user.password = userInBase.password;
} }
let __filename = fileURLToPath(import.meta.url);
let __dirname = dirname(__filename);
console.log(__dirname);
let profilePicture = userInBase.picture.split("/").pop();
fs.rename(__dirname + "../uploads/profiles/" + profilePicture, __dirname + "../uploads/profiles/" + user.username + "." + profilePicture.split(".").pop(), (err) => {
if (err) {
logger.write("failed to update profile picture", 500);
console.error("Error renaming file:", err);
throw err;
}
});
profilePicture = user.username + "." + profilePicture.split(".").pop();
const updateQuery = `UPDATE users SET email = $1, username = $2, password = $3, picture = $4 WHERE id = $5 RETURNING id, email, username, picture`; const updateQuery = `UPDATE users SET email = $1, username = $2, password = $3, picture = $4 WHERE id = $5 RETURNING id, email, username, picture`;
const result = await client.query(updateQuery, [user.email, user.username, user.password, user.picture, id]); const result = await client.query(updateQuery, [user.email, user.username, user.password, profilePicture, id]);
logger.write("successfully updated user " + id, 200); logger.write("successfully updated user " + id, 200);
res.status(200).send({user: result.rows[0]}); res.status(200).send({user: result.rows[0]});
} catch (err) { } catch (err) {

BIN
backend/app/uploads/profiles/astri6.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

BIN
backend/app/uploads/profiles/astri7.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

BIN
backend/app/uploads/profiles/astria2.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

BIN
backend/app/uploads/profiles/astria3.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

98
backend/logs/access.log

@ -1295,3 +1295,101 @@
[2025-07-21 13:56:56.344] [undefined] GET(/:id/history): try to retrieve history of user 2 [2025-07-21 13:56:56.344] [undefined] GET(/:id/history): try to retrieve history of user 2
[2025-07-21 13:56:56.354] [undefined] GET(/:id/history): failed to retrieve history of user 2 because it doesn't exist with status 404 [2025-07-21 13:56:56.354] [undefined] GET(/:id/history): failed to retrieve history of user 2 because it doesn't exist with status 404
[2025-07-21 13:56:56.363] [undefined] GET(/user/:id): Playlists retrieved for user with id 2 with status 200 [2025-07-21 13:56:56.363] [undefined] GET(/user/:id): Playlists retrieved for user with id 2 with status 200
[2025-07-21 15:07:33.098] [undefined] POST(/): try to register a user with username: astria2 and email: kjhkjhdf@sdfsdf.fr
[2025-07-21 15:07:33.203] [undefined] POST(/): successfully registered with status 200
[2025-07-21 15:07:33.257] [undefined] POST(/login): try to login with username 'astria2'
[2025-07-21 15:07:33.337] [undefined] POST(/login): Successfully logged in with status 200
[2025-07-21 15:07:39.330] [undefined] GET(/:id/history): try to retrieve history of user 3
[2025-07-21 15:07:39.333] [undefined] GET(/:id/channel): try to retrieve channel of user 3
[2025-07-21 15:07:39.336] [undefined] GET(/:id/channel): failed to retrieve channel of user 3 because it doesn't exist with status 404
[2025-07-21 15:07:39.343] [undefined] GET(/:id/history): failed to retrieve history of user 3 because it doesn't exist with status 404
[2025-07-21 15:07:39.361] [undefined] GET(/user/:id): Playlists retrieved for user with id 3 with status 200
[2025-07-21 15:07:44.508] [undefined] PUT(/:id): try to update user 3
[2025-07-21 15:07:44.521] [undefined] PUT(/:id): successfully updated user 3 with status 200
[2025-07-21 15:12:03.740] [undefined] POST(/): try to register a user with username: astria3 and email: jndsjdsjdsjlk@qsd.fr
[2025-07-21 15:12:03.837] [undefined] POST(/): successfully registered with status 200
[2025-07-21 15:12:03.892] [undefined] POST(/login): try to login with username 'astria3'
[2025-07-21 15:12:03.972] [undefined] POST(/login): Successfully logged in with status 200
[2025-07-21 15:12:16.800] [undefined] GET(/:id/channel): try to retrieve channel of user 4
[2025-07-21 15:12:16.805] [undefined] GET(/:id/history): try to retrieve history of user 4
[2025-07-21 15:12:16.812] [undefined] GET(/:id/channel): failed to retrieve channel of user 4 because it doesn't exist with status 404
[2025-07-21 15:12:16.823] [undefined] GET(/:id/history): failed to retrieve history of user 4 because it doesn't exist with status 404
[2025-07-21 15:12:16.838] [undefined] GET(/user/:id): Playlists retrieved for user with id 4 with status 200
[2025-07-21 15:12:22.148] [undefined] PUT(/:id): try to update user 4
[2025-07-21 15:12:22.154] [undefined] PUT(/:id): failed to update profile picture with status 500
[2025-07-21 15:12:22.156] [undefined] PUT(/:id): successfully updated user 4 with status 200
[2025-07-21 15:12:26.728] [undefined] GET(/:id/channel): try to retrieve channel of user 4
[2025-07-21 15:12:26.730] [undefined] GET(/:id/history): try to retrieve history of user 4
[2025-07-21 15:12:26.732] [undefined] GET(/:id/channel): failed to retrieve channel of user 4 because it doesn't exist with status 404
[2025-07-21 15:12:26.740] [undefined] GET(/user/:id): Playlists retrieved for user with id 4 with status 200
[2025-07-21 15:12:26.751] [undefined] GET(/:id/history): failed to retrieve history of user 4 because it doesn't exist with status 404
[2025-07-21 15:12:30.959] [undefined] PUT(/:id): try to update user 4
[2025-07-21 15:12:30.969] [undefined] PUT(/:id): failed to update profile picture with status 500
[2025-07-21 15:12:30.980] [undefined] PUT(/:id): successfully updated user 4 with status 200
[2025-07-21 15:12:34.141] [undefined] GET(/:id/channel): try to retrieve channel of user 4
[2025-07-21 15:12:34.144] [undefined] GET(/:id/channel): failed to retrieve channel of user 4 because it doesn't exist with status 404
[2025-07-21 15:12:34.171] [undefined] GET(/:id/history): try to retrieve history of user 4
[2025-07-21 15:12:34.177] [undefined] GET(/user/:id): Playlists retrieved for user with id 4 with status 200
[2025-07-21 15:12:34.188] [undefined] GET(/:id/history): failed to retrieve history of user 4 because it doesn't exist with status 404
[2025-07-21 15:13:02.119] [undefined] PUT(/:id): try to update user 4
[2025-07-21 15:13:02.121] [undefined] PUT(/:id): failed to update profile picture with status 500
[2025-07-21 15:13:02.131] [undefined] PUT(/:id): successfully updated user 4 with status 200
[2025-07-21 15:13:19.979] [undefined] GET(/:id/channel): try to retrieve channel of user 4
[2025-07-21 15:13:19.981] [undefined] GET(/:id/history): try to retrieve history of user 4
[2025-07-21 15:13:19.988] [undefined] GET(/:id/channel): failed to retrieve channel of user 4 because it doesn't exist with status 404
[2025-07-21 15:13:20.013] [undefined] GET(/user/:id): Playlists retrieved for user with id 4 with status 200
[2025-07-21 15:13:20.020] [undefined] GET(/:id/history): failed to retrieve history of user 4 because it doesn't exist with status 404
[2025-07-21 15:13:23.974] [undefined] PUT(/:id): try to update user 4
[2025-07-21 15:13:23.988] [undefined] PUT(/:id): failed to update profile picture with status 500
[2025-07-21 15:13:24.017] [undefined] PUT(/:id): successfully updated user 4 with status 200
[2025-07-21 15:14:38.178] [undefined] PUT(/:id): try to update user 4
[2025-07-21 15:14:38.185] [undefined] PUT(/:id): successfully updated user 4 with status 200
[2025-07-21 15:14:41.114] [undefined] GET(/:id/history): try to retrieve history of user 4
[2025-07-21 15:14:41.121] [undefined] GET(/:id/channel): try to retrieve channel of user 4
[2025-07-21 15:14:41.122] [undefined] GET(/:id/history): failed to retrieve history of user 4 because it doesn't exist with status 404
[2025-07-21 15:14:41.125] [undefined] GET(/:id/channel): failed to retrieve channel of user 4 because it doesn't exist with status 404
[2025-07-21 15:14:41.136] [undefined] GET(/user/:id): Playlists retrieved for user with id 4 with status 200
[2025-07-21 15:17:30.716] [undefined] POST(/): try to register a user with username: astri5 and email: sachaguerin@gmail.com
[2025-07-21 15:17:30.803] [undefined] POST(/): successfully registered with status 200
[2025-07-21 15:17:30.844] [undefined] POST(/login): try to login with username 'astri5'
[2025-07-21 15:17:30.911] [undefined] POST(/login): Successfully logged in with status 200
[2025-07-21 15:17:37.485] [undefined] GET(/:id/channel): try to retrieve channel of user 5
[2025-07-21 15:17:37.487] [undefined] GET(/:id/channel): failed to retrieve channel of user 5 because it doesn't exist with status 404
[2025-07-21 15:17:37.489] [undefined] GET(/:id/history): try to retrieve history of user 5
[2025-07-21 15:17:37.492] [undefined] GET(/:id/history): failed to retrieve history of user 5 because it doesn't exist with status 404
[2025-07-21 15:17:37.511] [undefined] GET(/user/:id): Playlists retrieved for user with id 5 with status 200
[2025-07-21 15:17:46.134] [undefined] PUT(/:id): try to update user 5
[2025-07-21 15:17:46.139] [undefined] PUT(/:id): failed to update profile picture with status 500
[2025-07-21 15:19:54.389] [undefined] GET(/:id/channel): try to retrieve channel of user 5
[2025-07-21 15:19:54.392] [undefined] GET(/:id/history): try to retrieve history of user 5
[2025-07-21 15:19:54.402] [undefined] GET(/:id/channel): failed to retrieve channel of user 5 because it doesn't exist with status 404
[2025-07-21 15:19:54.411] [undefined] GET(/:id/history): failed to retrieve history of user 5 because it doesn't exist with status 404
[2025-07-21 15:19:54.429] [undefined] GET(/user/:id): Playlists retrieved for user with id 5 with status 200
[2025-07-21 15:20:01.308] [undefined] PUT(/:id): try to update user 5
[2025-07-21 15:20:01.316] [undefined] PUT(/:id): successfully updated user 5 with status 200
[2025-07-21 15:22:58.198] [undefined] GET(/:id/channel): try to retrieve channel of user 5
[2025-07-21 15:22:58.245] [undefined] GET(/:id/channel): failed to retrieve channel of user 5 because it doesn't exist with status 404
[2025-07-21 15:22:58.258] [undefined] GET(/:id/history): try to retrieve history of user 5
[2025-07-21 15:22:58.296] [undefined] GET(/:id/history): failed to retrieve history of user 5 because it doesn't exist with status 404
[2025-07-21 15:22:58.336] [undefined] GET(/user/:id): Playlists retrieved for user with id 5 with status 200
[2025-07-21 15:23:13.591] [undefined] GET(/:id/history): try to retrieve history of user 5
[2025-07-21 15:23:13.596] [undefined] GET(/:id/channel): try to retrieve channel of user 5
[2025-07-21 15:23:13.602] [undefined] GET(/:id/history): failed to retrieve history of user 5 because it doesn't exist with status 404
[2025-07-21 15:23:13.611] [undefined] GET(/:id/channel): failed to retrieve channel of user 5 because it doesn't exist with status 404
[2025-07-21 15:23:13.636] [undefined] GET(/user/:id): Playlists retrieved for user with id 5 with status 200
[2025-07-21 15:23:16.400] [undefined] GET(/:id/channel): try to retrieve channel of user 5
[2025-07-21 15:23:16.405] [undefined] GET(/:id/history): try to retrieve history of user 5
[2025-07-21 15:23:16.409] [undefined] GET(/:id/channel): failed to retrieve channel of user 5 because it doesn't exist with status 404
[2025-07-21 15:23:16.413] [undefined] GET(/:id/history): failed to retrieve history of user 5 because it doesn't exist with status 404
[2025-07-21 15:23:16.442] [undefined] GET(/user/:id): Playlists retrieved for user with id 5 with status 200
[2025-07-21 15:23:38.610] [undefined] POST(/): try to register a user with username: astri7 and email: erjfhiurfhiu@sdf.sdf
[2025-07-21 15:23:38.701] [undefined] POST(/): successfully registered with status 200
[2025-07-21 15:23:38.734] [undefined] POST(/login): try to login with username 'astri7'
[2025-07-21 15:23:38.800] [undefined] POST(/login): Successfully logged in with status 200
[2025-07-21 15:23:44.502] [undefined] GET(/:id/history): try to retrieve history of user 6
[2025-07-21 15:23:44.507] [undefined] GET(/:id/history): failed to retrieve history of user 6 because it doesn't exist with status 404
[2025-07-21 15:23:44.518] [undefined] GET(/:id/channel): try to retrieve channel of user 6
[2025-07-21 15:23:44.527] [undefined] GET(/:id/channel): failed to retrieve channel of user 6 because it doesn't exist with status 404
[2025-07-21 15:23:44.537] [undefined] GET(/user/:id): Playlists retrieved for user with id 6 with status 200
[2025-07-21 15:23:49.626] [undefined] PUT(/:id): try to update user 6
[2025-07-21 15:23:49.633] [undefined] PUT(/:id): failed to update profile picture with status 500

Loading…
Cancel
Save