Commit c2ab879
committed
fix(1439): kick-only flow no longer tells the player they were banned
Right-clicking a player on `?p=servers` and choosing "Kick player" loads
the kickit iframe, which until now ran the post-ban-completion code path
unconditionally — emitting the rcon kick reason
"You have been banned by this server, check $domain for more info" and
re-attributing whatever active ban happened to share the SteamID to the
kick target's server (UPDATE :prefix_bans SET sid = ... WHERE authid = ...
AND RemovedBy IS NULL). The reporter on #1439 saw the wrong message; the
silent audit-trail corruption was the worse half of the bug.
The fix carries an explicit `mode` signal end-to-end:
- The context menu's Kick URL now appends `&mode=kick` (the post-ban
iframe embed inside `admin.bans.php`'s "Ban Added" dialog stays on the
default `'ban'` mode).
- `admin.kickit.php` allowlists `$_GET['mode']` to `'ban'|'kick'`
(anything else coerces to `'ban'` — backward-compat with pre-#1439
callers that don't supply the param).
- `KickitView` carries the mode through to `page_kickit.tpl` which
branches the `<title>` ("Kick player" vs "Ban player"), surfaces a
`data-mode` attribute on the container for third-party theme styling,
and forwards the value as `mode` on every `kickit.kick_player` JSON
call.
- `api_kickit_kick_player` re-validates the mode and gates two things on
it: the `:prefix_bans` UPDATE is skipped on kick mode (extracted into
`_api_kickit_should_update_ban_sid` for testability + clarity), and
the rcon kick reason is now "You have been kicked from this server"
on kick mode (still "You have been banned by this server, check ..."
on ban mode).
- The iframe's post-completion redirect lands the operator back on
`?p=servers` for the kick flow (where they came from), preserving the
existing `?p=admin&c=bans` destination for ban mode.
Coverage:
- `KickitTest` (15 cases, 82 assertions) — handler-shape coverage for
both modes + the unknown-mode coercion, the rcon-message branch via
`_api_kickit_build_kick_message`, and the ban-UPDATE gate via the new
`_api_kickit_should_update_ban_sid` helper (incl. a static-analysis
guard that the handler invokes the helper rather than inlining the
`$mode === 'ban'` check around the UPDATE).
- `kickit-iframe.spec.ts` adds an E2E case driving the full kick flow:
title says "Kick player", `kickit.kick_player` payload carries
`mode: 'kick'`, and the post-completion `window.location` flip lands
on `index.php?p=servers` (anchored on real `waitForURL` against the
actual 5s redirect timer — source-grep on the script body would
silently accept a regression that deleted the kick-mode arm).
- `server-player-context-menu.spec.ts` updated to expect `&mode=kick`
in the Kick item's href.
Documentation in AGENTS.md (context-menu prose + "Where to find what"
table + regression-guards section) extended to spell the `mode`
contract end-to-end so future readers don't re-discover the failure
mode.
Adversarial reviewer pass also caught: ban-mode UPDATE SQL was
incorrectly transcribed as `removetype = 'X'` in AGENTS.md (now
`sid = :sid WHERE authid = :authid AND RemovedBy IS NULL`); the new
unit tests now also assert the `mode` field is consumed by the handler
and not echoed back in the API response.
Fixes: #14391 parent f2b0bc6 commit c2ab879
10 files changed
Lines changed: 672 additions & 36 deletions
File tree
- web
- api/handlers
- includes/View
- pages
- scripts
- tests
- api
- e2e/specs/flows
- themes/default
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
48 | 73 | | |
49 | 74 | | |
50 | 75 | | |
| |||
60 | 85 | | |
61 | 86 | | |
62 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
63 | 96 | | |
64 | 97 | | |
65 | 98 | | |
| |||
117 | 150 | | |
118 | 151 | | |
119 | 152 | | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
120 | 156 | | |
121 | 157 | | |
122 | 158 | | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
130 | 171 | | |
131 | 172 | | |
132 | 173 | | |
133 | 174 | | |
134 | 175 | | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
139 | 182 | | |
140 | | - | |
141 | | - | |
| 183 | + | |
142 | 184 | | |
143 | 185 | | |
144 | 186 | | |
| |||
147 | 189 | | |
148 | 190 | | |
149 | 191 | | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
22 | 29 | | |
23 | 30 | | |
24 | 31 | | |
| |||
37 | 44 | | |
38 | 45 | | |
39 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
40 | 54 | | |
41 | 55 | | |
42 | 56 | | |
43 | 57 | | |
44 | 58 | | |
45 | 59 | | |
46 | 60 | | |
| 61 | + | |
47 | 62 | | |
48 | 63 | | |
49 | 64 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
31 | 43 | | |
32 | 44 | | |
33 | 45 | | |
34 | 46 | | |
35 | 47 | | |
36 | 48 | | |
37 | 49 | | |
| 50 | + | |
38 | 51 | | |
39 | 52 | | |
40 | 53 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
351 | 351 | | |
352 | 352 | | |
353 | 353 | | |
354 | | - | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
355 | 373 | | |
356 | 374 | | |
357 | 375 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
354 | 354 | | |
355 | 355 | | |
356 | 356 | | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
357 | 372 | | |
358 | 373 | | |
359 | 374 | | |
| |||
384 | 399 | | |
385 | 400 | | |
386 | 401 | | |
387 | | - | |
| 402 | + | |
388 | 403 | | |
389 | 404 | | |
390 | 405 | | |
| |||
0 commit comments