fest: throw an error if application name is empty

This commit is contained in:
CyberL1
2026-01-14 16:11:36 +01:00
parent e274ae107d
commit 349211bdcd

View File

@@ -17,7 +17,7 @@
*/
import { route } from "@spacebar/api";
import { Application, DiscordApiErrors, Guild, handleFile, User } from "@spacebar/util";
import { Application, DiscordApiErrors, FieldErrors, Guild, handleFile, User } from "@spacebar/util";
import { Request, Response, Router } from "express";
import { HTTPError } from "lambert-server";
import { verifyToken } from "node-2fa";
@@ -73,6 +73,15 @@ router.patch(
if (app.owner.totp_secret && (!req.body.code || verifyToken(app.owner.totp_secret, req.body.code))) throw new HTTPError(req.t("auth:login.INVALID_TOTP_CODE"), 60008);
if (body.name?.trim() == "") {
throw FieldErrors({
name: {
code: "BASE_TYPE_REQUIRED",
message: req.t("common:field.BASE_TYPE_REQUIRED"),
},
});
}
if (body.icon) {
body.icon = await handleFile(`/app-icons/${app.id}`, body.icon as string);
}