fix(api): mc_uuid 统一校验为 UUID,非法值返回 400 bad_mc_uuid 并按规范形式存储

This commit is contained in:
Lemon-miaow committed 2026-09-27 12:57:40 +08:00
1 parent 5b0686dc06
commit e91886822c
13 files changed
+159 -35

No files matched your search

@@ -4,6 +4,7 @@
"not_linked": "Link your Minecraft account before claiming (Account → Link).",
"invalid_code": "That code is invalid or expired — request a fresh one and try again.",
"already_linked": "That Minecraft account is already linked to another user.",
"bad_mc_uuid": "That isn't a Minecraft UUID. It looks like 069a79f4-44e9-4726-a5be-fca90e38aaf5, with or without the dashes.",
"quota_exceeded": "You have reached your server quota.",
"already_claimed": "Someone else just claimed this server.",
"image_not_whitelisted": "That image is not on the whitelist.",
@@ -4,6 +4,7 @@
"not_linked": "请先关联 Minecraft 账户(账户页 → 关联)。",
"invalid_code": "代码无效或已过期——请重新获取后再试。",
"already_linked": "该 Minecraft 账户已关联至其他用户。",
"bad_mc_uuid": "这不是 Minecraft UUID。它的样子是 069a79f4-44e9-4726-a5be-fca90e38aaf5,短横线可带可不带。",
"quota_exceeded": "服务器数量已达配额上限。",
"already_claimed": "该服务器已被他人抢先认领。",
"image_not_whitelisted": "该镜像未在白名单中。",
+6
View File
@@ -438,6 +438,12 @@ describe("api access-control wire shapes", () => {
);
});
it("says what a Minecraft UUID looks like when the typed one is not", () => {
expect(humanizeError({ status: 400, code: "bad_mc_uuid" })).toBe(
"That isn't a Minecraft UUID. It looks like 069a79f4-44e9-4726-a5be-fca90e38aaf5, with or without the dashes.",
);
});
it("says email codes are off when the install has no mail relay", async () => {
const { humanizeError } = await import("./api");
expect(humanizeError({ status: 503, code: "mail_unavailable" })).toBe(
+2
View File
@@ -1002,6 +1002,8 @@ export function humanizeError(e: unknown): string {
return t("invalid_code");
case "already_linked":
return t("already_linked");
case "bad_mc_uuid":
return t("bad_mc_uuid");
case "otp_resend_cooldown":
return t("otp_resend_cooldown");
case "otp_locked":
+4
View File
@@ -3427,6 +3427,7 @@ export interface operations {
};
};
};
400: components["responses"]["BadRequest"];
401: components["responses"]["Unauthorized"];
};
};
@@ -3491,6 +3492,7 @@ export interface operations {
};
};
};
400: components["responses"]["BadRequest"];
401: components["responses"]["Unauthorized"];
};
};
@@ -3615,6 +3617,7 @@ export interface operations {
};
};
};
400: components["responses"]["BadRequest"];
401: components["responses"]["Unauthorized"];
};
};
@@ -6651,6 +6654,7 @@ export interface operations {
};
};
};
400: components["responses"]["BadRequest"];
401: components["responses"]["Unauthorized"];
403: components["responses"]["Forbidden"];
/** @description No linked account for this UUID. */