Add player action logging for admin operations
Introduces a new addPlayerAction method in adminRepository and logPlayerAction in adminService to record admin actions on player accounts. Updates relevant admin routes to log actions such as bans, unbans, forced name changes, and skin resets. Also improves error messages in adminService for consistency and clarity.
This commit is contained in:
@@ -85,7 +85,7 @@ function hasPermission(requiredPermission) {
|
||||
try {
|
||||
const authHeader = req.headers.authorization
|
||||
if (!authHeader || !authHeader.startsWith("Bearer ")) {
|
||||
throw new DefaultError(401, "Authentification admin requise.")
|
||||
throw new DefaultError(401, "Admin auth required.")
|
||||
}
|
||||
|
||||
const token = authHeader.split(" ")[1]
|
||||
@@ -117,29 +117,35 @@ async function uploadCape(fileObject, alias = null) {
|
||||
const hash = crypto.createHash("sha256").update(buffer).digest("hex")
|
||||
|
||||
const existing = await userRepository.getTextureByHash(hash)
|
||||
if (existing) throw new DefaultError(409, "Cette cape existe déjà.")
|
||||
if (existing) throw new DefaultError(409, "Cape already existing.")
|
||||
|
||||
const textureUrl = `/texture/${hash}`
|
||||
await userRepository.createTexture(crypto.randomUUID(), hash, 'CAPE', textureUrl, alias)
|
||||
await userRepository.createTexture(crypto.randomUUID(), hash, "CAPE", textureUrl, alias)
|
||||
|
||||
return { hash, url: textureUrl }
|
||||
}
|
||||
|
||||
async function deleteGlobalCape(hash) {
|
||||
const success = await userRepository.deleteTexture(hash)
|
||||
if (!success) throw new DefaultError(404, "Cape introuvable.")
|
||||
if (!success) throw new DefaultError(404, "Cape not found.")
|
||||
|
||||
return { message: "Texture supprimée globalement." }
|
||||
return { message: "Texture removed." }
|
||||
}
|
||||
|
||||
async function logPlayerAction(playerUuid, actionCode) {
|
||||
return await adminRepository.addPlayerAction(playerUuid, actionCode)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
loginAdmin,
|
||||
uploadCape,
|
||||
registerAdmin,
|
||||
hasPermission,
|
||||
getAdminProfile,
|
||||
grantPermission,
|
||||
revokePermission,
|
||||
checkAdminAccess,
|
||||
deleteGlobalCape,
|
||||
logPlayerAction,
|
||||
changeAdminPassword,
|
||||
hasPermission,
|
||||
}
|
||||
Reference in New Issue
Block a user