mirror of
https://github.com/KeyZox71/knl_meowscendence.git
synced 2025-08-14 04:22:54 +02:00
「♻️」 refactor: change /create to /users/:userId
This commit is contained in:
@ -120,15 +120,12 @@ export default async function(fastify, options) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// POST
|
// POST
|
||||||
fastify.post('/create', { preHandler: [fastify.authenticateAdmin] }, async (request, reply) => {
|
fastify.post('/users/:userId', { preHandler: [fastify.authenticateAdmin] }, async (request, reply) => {
|
||||||
try {
|
try {
|
||||||
if (!request.body || !request.body.user) {
|
if (getUserInfo.get(userId)) {
|
||||||
return reply.code(400).send({ error: "Please specify a user" });
|
|
||||||
}
|
|
||||||
if (getUserInfo.get(request.body.user)) {
|
|
||||||
return reply.code(400).send({ error: "User already exist" });
|
return reply.code(400).send({ error: "User already exist" });
|
||||||
}
|
}
|
||||||
createUser.run(request.body.user, request.body.user);
|
createUser.run(request.params.userId, request.params.userId);
|
||||||
return reply.code(200).send({ msg: "User created sucessfully" });
|
return reply.code(200).send({ msg: "User created sucessfully" });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
fastify.log.error(err);
|
fastify.log.error(err);
|
||||||
@ -213,7 +210,7 @@ export default async function(fastify, options) {
|
|||||||
changeDisplayName.run("", request.params.userId);
|
changeDisplayName.run("", request.params.userId);
|
||||||
return reply.code(200).send({ msg: "displayName cleared sucessfully" });
|
return reply.code(200).send({ msg: "displayName cleared sucessfully" });
|
||||||
}
|
}
|
||||||
return reply.code(400).send({ msg: "member does not exist"})
|
return reply.code(400).send({ msg: "member does not exist" })
|
||||||
} else {
|
} else {
|
||||||
return reply.code(401).send({ error: 'You dont have the right to delete this' });
|
return reply.code(401).send({ error: 'You dont have the right to delete this' });
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user