clantag part 1 (#4066)

If this PR fixes an issue, link it below. If not, delete these two
lines.
Resolves #(issue number)

## Description:

adds a check to see if you're in a clan or not. if not, checks to see if
the clan exists, if it does, warns the user, if it doesn't, lets them
use it.

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced

## Please put your Discord username so you can be contacted if a bug or
regression is found:

w.o.n
This commit is contained in:
Ryan
2026-06-03 14:25:55 -07:00
committed by GitHub
parent 297e1f579e
commit 9c2ac05506
11 changed files with 430 additions and 16 deletions
+19 -1
View File
@@ -73,6 +73,7 @@ export async function startWorker() {
ServerEnv.jwtIssuer() + "/cosmetics.json",
ServerEnv.jwtIssuer() + "/profane_words_game_server",
ServerEnv.apiKey(),
ServerEnv.jwtIssuer() + "/reserved_clan_tags",
log,
);
privilegeRefresher.start();
@@ -378,6 +379,7 @@ export async function startWorker() {
let flares: string[] | undefined;
let publicId: string | undefined;
let friends: string[] = [];
let ownedClanTags: string[] = [];
const allowedFlares = ServerEnv.allowedFlares();
if (claims === null) {
@@ -400,6 +402,7 @@ export async function startWorker() {
flares = result.response.player.flares;
publicId = result.response.player.publicId;
friends = result.response.player.friends;
ownedClanTags = result.response.player.clans?.map((c) => c.tag) ?? [];
if (allowedFlares !== undefined) {
const allowed =
@@ -415,6 +418,21 @@ export async function startWorker() {
}
}
// Enforce clan tag ownership: a player can wear a tag only if they're
// a member; a real clan they're not in (or an unverifiable tag) is
// dropped to prevent impersonation. Fictional tags pass through.
const resolution = privilegeRefresher
.get()
.resolveClanTag(censoredClanTag, ownedClanTags);
if (resolution.dropped) {
log.warn("Dropped clan tag: player is not a member", {
persistentID: persistentId,
gameID: clientMsg.gameID,
clanTag: censoredClanTag,
});
}
const resolvedClanTag = resolution.tag;
const cosmeticResult = privilegeRefresher
.get()
.isAllowed(flares ?? [], clientMsg.cosmetics ?? {});
@@ -463,7 +481,7 @@ export async function startWorker() {
flares,
ip,
censoredUsername,
censoredClanTag,
resolvedClanTag,
ws,
cosmeticResult.cosmetics,
publicId,