Commit 7032ed2
fix: updated the createdBy in plg onboarding (#2398)
## fix: stamp customer identity as `createdBy` on PLG onboarding for
pre-seeded records
### Problem
When a PLG onboarding record is pre-seeded by an admin with
`PRE_ONBOARDING` or `INACTIVE` status, the `createdBy` field is set to
`'system'` (or the admin identity). When the real customer later
triggers the onboarding flow for that domain, `updatedBy` correctly
captured their identity but `createdBy` remained as `'system'` —
misrepresenting who actually initiated the onboarding.
### Solution
In `performAsoPlgOnboarding`, after setting `updatedBy`, stamp
`createdBy` with the caller's identity when the existing record's status
is `PRE_ONBOARDING` or `INACTIVE`. These are the two statuses that
indicate a record was pre-seeded before the customer triggered the flow.
```js
onboarding.setUpdatedBy(callerIdentity);
if ([STATUSES.PRE_ONBOARDING, STATUSES.INACTIVE].includes(onboarding.getStatus())) {
onboarding.setCreatedBy(callerIdentity);
}
```
### Changes
- **`src/controllers/plg/plg-onboarding.js`** — sets `createdBy` to the
real caller identity when resuming a `PRE_ONBOARDING` or `INACTIVE`
record
- **`test/controllers/plg/plg-onboarding.test.js`** — adds 3 unit tests
covering PRE_ONBOARDING, INACTIVE, and the no-op case for other statuses
### Testing
- All 330 unit tests pass
- Covered scenarios:
- `PRE_ONBOARDING` record → `createdBy` updated to customer email
- `INACTIVE` record → `createdBy` updated to customer email
- Any other status (e.g. `IN_PROGRESS`) → `createdBy` left unchanged
Please ensure your pull request adheres to the following guidelines:
- [ ] make sure to link the related issues in this description. Or if
there's no issue created, make sure you
describe here the problem you're solving.
- [ ] when merging / squashing, make sure the fixed issue references are
visible in the commits, for easy compilation of release notes
If the PR is changing the API specification:
- [ ] make sure you add a "Not implemented yet" note the endpoint
description, if the implementation is not ready
yet. Ideally, return a 501 status code with a message explaining the
feature is not implemented yet.
- [ ] make sure you add at least one example of the request and
response.
If the PR is changing the API implementation or an entity exposed
through the API:
- [ ] make sure you update the API specification and the examples to
reflect the changes.
If the PR is introducing a new audit type:
- [ ] make sure you update the API specification with the type, schema
of the audit result and an example
## Related Issues
Thanks for contributing!
Co-authored-by: Anshul Kumar <anshulk@Anshuls-MacBook-Pro-2.local>1 parent d7889ac commit 7032ed2
2 files changed
Lines changed: 29 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
704 | 704 | | |
705 | 705 | | |
706 | 706 | | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
707 | 710 | | |
708 | 711 | | |
709 | 712 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3209 | 3209 | | |
3210 | 3210 | | |
3211 | 3211 | | |
| 3212 | + | |
| 3213 | + | |
| 3214 | + | |
| 3215 | + | |
| 3216 | + | |
| 3217 | + | |
| 3218 | + | |
| 3219 | + | |
| 3220 | + | |
| 3221 | + | |
| 3222 | + | |
| 3223 | + | |
| 3224 | + | |
| 3225 | + | |
| 3226 | + | |
| 3227 | + | |
| 3228 | + | |
| 3229 | + | |
| 3230 | + | |
| 3231 | + | |
| 3232 | + | |
| 3233 | + | |
| 3234 | + | |
| 3235 | + | |
| 3236 | + | |
| 3237 | + | |
3212 | 3238 | | |
3213 | 3239 | | |
3214 | 3240 | | |
| |||
0 commit comments