mirror of
https://github.com/KeyZox71/knl_meowscendence.git
synced 2025-12-31 21:56:41 +01:00
「🔨」 fix(user-management): fix the fact the no fucking route was protected
This commit is contained in:
@ -1,22 +1,19 @@
|
||||
export async function dMember(request, reply, fastify, getUserInfo, changeDisplayName) {
|
||||
try {
|
||||
if (!request.user) {
|
||||
return reply.code(400).send({ error: "Please specify a user" });
|
||||
}
|
||||
const userId = request.params.userId;
|
||||
if (request.user !== userId && request.user !== 'admin') {
|
||||
return reply.code(401).send({ error: 'Unauthorized' });
|
||||
}
|
||||
if (!getUserInfo.get(userId)) {
|
||||
return reply.code(404).send({ error: "User does not exist" });
|
||||
}
|
||||
const user = request.user;
|
||||
const member = request.params.member;
|
||||
if (user === 'admin' || user === request.params.userId) {
|
||||
if (member === 'displayName') {
|
||||
changeDisplayName.run("", request.params.userId);
|
||||
return reply.code(200).send({ msg: "Display name deleted successfully" });
|
||||
}
|
||||
return reply.code(400).send({ msg: "Member does not exist" })
|
||||
if (member === 'displayName') {
|
||||
changeDisplayName.run("", request.params.userId);
|
||||
return reply.code(200).send({ msg: "Display name deleted successfully" });
|
||||
} else {
|
||||
return reply.code(401).send({ error: 'You dont have the right to delete this' });
|
||||
return reply.code(400).send({ msg: "Member does not exist" })
|
||||
}
|
||||
} catch (err) {
|
||||
fastify.log.error(err);
|
||||
|
||||
Reference in New Issue
Block a user