mirror of
https://github.com/KeyZox71/knl_meowscendence.git
synced 2025-12-31 21:56:41 +01:00
「🔨」 fix(auth): remove working now
This commit is contained in:
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user