clantag part 1#4066
Conversation
|
Caution Review failedFailed to post review comments WalkthroughThis PR wires asynchronous clan-tag ownership checks end-to-end: API path + i18n, client probes and ownership API, UsernameInput async UI and promise exposure, join gating via LobbyConfig, and server privilege resolution enforcing or dropping tags during join. ChangesClan Tag Ownership Validation
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| // Existence-probe path (200 = exists, 404 = not); uppercased to match the | ||
| // canonical tag form. Shared so the client probe and server enforcement agree. | ||
| export function clanExistsApiPath(tag: string): string { | ||
| return `/public/clan/${encodeURIComponent(tag.toUpperCase())}/exists`; | ||
| } |
There was a problem hiding this comment.
i think this should go to clanapi
There was a problem hiding this comment.
now in clanapischema because didn't make sense to put in /client/clanapi
as it's used for both client and server
| * and null when the result is inconclusive (transport error, timeout, or | ||
| * unexpected status). Callers treat null as fail-closed (drop the tag). | ||
| */ | ||
| export async function clanExistsByTag( |
There was a problem hiding this comment.
this functions should be methods on Privilege.ts
|
|
||
| // Try to reconnect an existing client (e.g., page refresh). Pre-game, | ||
| // username and clan tag pick up the latest validated values from this | ||
| // connection. | ||
| if ( | ||
| gm.rejoinClient(ws, persistentId, clientMsg.gameID, 0, { | ||
| username: censoredUsername, | ||
| clanTag: resolvedClanTag, | ||
| }) | ||
| ) { | ||
| return; | ||
| } | ||
|
|
||
| // New client — finish the join checks. | ||
| const flares = userMeResponse?.player.flares; | ||
| const publicId = userMeResponse?.player.publicId; | ||
| const friends = userMeResponse?.player.friends ?? []; | ||
|
|
||
| if (userMeResponse !== null && allowedFlares !== undefined) { | ||
| const allowed = | ||
| allowedFlares.length === 0 || | ||
| allowedFlares.some((f) => flares?.includes(f)); | ||
| if (!allowed) { | ||
| log.warn( | ||
| "Forbidden: player without an allowed flare attempted to join game", | ||
| ); | ||
| ws.close(1002, "Forbidden"); | ||
| return; |
There was a problem hiding this comment.
this originally was a coderabbit comment, but reduced to make it only be the clan tag stuff
If this PR fixes an issue, link it below. If not, delete these two lines.
Resolves #(issue number)
Description:
Describe the PR.
Please complete the following:
Please put your Discord username so you can be contacted if a bug or regression is found:
DISCORD_USERNAME