🔨」 fix(auth): remove working now

This commit is contained in:
2025-10-23 16:00:24 +02:00
parent 3c1c22a441
commit e15cb8e776
4 changed files with 9 additions and 8 deletions

View File

@ -1,16 +1,16 @@
export async function dUser(request, reply, fastify, getUserInfo, deleteMatchHistory, deleteFriends, deleteUser) {
try {
const userId = request.params.userId;
if (request.user !== userId && request.user !== 'admin') {
if (request.user !== 'admin') {
return reply.code(401).send({ error: 'Unauthorized' });
}
const userId = request.params.userId;
if (!getUserInfo.get(userId)) {
return reply.code(404).send({ error: "User does not exist" });
}
deleteMatchHistory.run('pong', request.params.userId);
deleteMatchHistory.run('tetris', request.params.userId);
deleteFriends.run(request.params.userId);
deleteUser.run(request.params.userId);
deleteMatchHistory.run('pong', userId);
deleteMatchHistory.run('tetris', userId);
deleteFriends.run(userId);
deleteUser.run(userId);
return reply.code(200).send({ msg: "User deleted successfully" });
} catch (err) {
fastify.log.error(err);

View File

@ -7,6 +7,7 @@ export async function gUser(request, reply, fastify, getUserInfo) {
if (!getUserInfo.get(userId)) {
return reply.code(404).send({ error: "User does not exist" });
}
const userInfo = getUserInfo.get(userId);
return reply.code(200).send({
username: userInfo.username,
displayName: userInfo.displayName,

View File

@ -83,7 +83,7 @@ function getUser(user) {
}
function rmUser(user) {
const stmt = database.prepare('DELETE * FROM credentials WHERE username = ?');
const stmt = database.prepare('DELETE FROM credentials WHERE username = ?');
stmt.run(user);
}

View File

@ -8,7 +8,7 @@ export async function authUserRemove(username, fastify) {
const url = (process.env.USER_URL || "http://localhost:3002") + "/users/" + username;
const cookie = fastify.jwt.sign({ user: "admin" });
await axios.post(
await axios.delete(
url,
{
headers: {