Commit b00684c
feat(jwt): expand FK fields in login response data (SESSION_RETURN_FK parity)
HMAC SessionController sets getFKTables = SESSION_RETURN_FK (default
true), causing getObject() to recursively expand FK integers into
full nested objects. JWT userToArray was returning raw FK ints, so
frontend code like 'user.org.org_type' silently failed (org was '2',
not {id:2, org_type:'LP'}).
Add FK expansion to userToArray:
- Walk model struct
- For fields with 'fk' definition + non-empty value, retrieve the
referenced ModelObject and recursively serialize it
- Bounded at depth 3 to prevent runaway recursion on cyclic FKs
Respects SESSION_RETURN_FK constant (defaults true, can be disabled
per-deployment). retrieve() handles dbswitch automatically based on
the FK model's appId, so app-scoped + default-scoped FKs both work.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 1445ca8 commit b00684c
1 file changed
Lines changed: 37 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
219 | 226 | | |
220 | | - | |
| 227 | + | |
221 | 228 | | |
222 | 229 | | |
223 | 230 | | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
224 | 234 | | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
225 | 239 | | |
226 | | - | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
227 | 257 | | |
228 | 258 | | |
| 259 | + | |
229 | 260 | | |
230 | 261 | | |
231 | 262 | | |
| |||
0 commit comments