Commit b08e9a3
authored
fix(users): admin GET /users/:id no longer leaks password hash and tokens (#3731)
* fix(users): admin GET /users/:id no longer leaks password hash and tokens
`get` handler called `req.model.toJSON()` (raw Mongoose doc, no strip)
while `list` correctly used `UserService.removeSensitive`. Aligns `get`
with `list` by routing through `removeSensitive`. Adds an integration
test asserting `password`, `resetPasswordToken`, `emailVerificationToken`,
and `salt` are absent from the response.
Closes #3723
* test(users): seed tokens before PII-leak assertion to make regression meaningful
The previous assertion would pass vacuously when resetPasswordToken and
emailVerificationToken are absent on the user. Seed both fields via
updateById before the admin GET so the test proves the leak is actually
blocked, not just that the fields were never present.
Addresses: #3731 (comment)...1 parent 0547013 commit b08e9a3
2 files changed
Lines changed: 41 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
225 | 225 | | |
226 | 226 | | |
227 | 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 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
228 | 268 | | |
229 | 269 | | |
230 | 270 | | |
| |||
0 commit comments