Skip to content

Conversation

Trighap52
Copy link

Description

This PR prevents an admin from deleting their own account while logged in. Previously, the admin could remove themselves from the app (from settings > admin) which resulted in a strange behavior. Now, a error is thrown if an admin tries to. I also updated the tests to correctly test the deletion (with a new mock and a new test case).

Related Issues

How can it be tested?

Try to delete yourself as an admin and an error shoul be thrown.
image

Check list before submitting

  • This PR is wrote in a clear language and correctly labeled
  • I created the related changeset for my changes with npx changeset
  • I have performed a self-review of my code (no debugs, no commented code, good naming, etc.)
  • I wrote the relative tests
  • I created a PR for the documentation if necessary and attached the link to this PR

Copy link

codecov bot commented Feb 24, 2025

Bundle Report

Changes will decrease total bundle size by 266.12kB (-13.18%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
manifest 1.75MB -266.12kB (-13.18%) ⬇️

Affected Assets, Files, and Routes:

view changes for bundle: manifest

Assets Changed:

Asset Name Size Change Total Size Change (%)
admin/main.*.js -1.18kB 434.91kB -0.27%
admin/styles.*.css -185.72kB 349.47kB -34.7%
assets/dummy-image.jpg -46.32kB 118.71kB -28.07%
admin/45.*.js 12 bytes 14.6kB 0.08%
assets/dummy-invoice.pdf -32.91kB 10.72kB -75.43%

Copy link

codecov bot commented Feb 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.27%. Comparing base (cb0f178) to head (baef673).
Report is 25 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #321   +/-   ##
=======================================
  Coverage   85.27%   85.27%           
=======================================
  Files          57       57           
  Lines        1623     1623           
  Branches      373      364    -9     
=======================================
  Hits         1384     1384           
- Misses        215      233   +18     
+ Partials       24        6   -18     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@brunobuddy
Copy link
Contributor

Hello @Trighap52 thanks for your contribution.

There is a conflict that has to be resolved. Can you check it ? Also we would need to add tests for this behavior.

@brunobuddy brunobuddy self-requested a review March 6, 2025 07:47
Copy link
Contributor

@brunobuddy brunobuddy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See previous comment

Copy link
Contributor

@brunobuddy brunobuddy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @Trighap52

Thank you for your changes, there is still an error in that code: it does not check that we are actually deleting ADMIN entity ! If I am logged as default admin with id 1 it will fail everytime I try to delete ANY item with ID 1.

Ensure that the "entity" param equals the admin slug (constants.ts) before.

Also be the "user.user" sounds a bit bad, maybe you can call it "requestUser.user", not perfect but sounds a bit better

@sahithvibudhi
Copy link

@Trighap52 are you still working on this? If not, I’d be happy to pick it up and help move it forward

@brunobuddy
Copy link
Contributor

@sahithvibudhi there is no news form @Trighap52 so you can take it from here if you want. Beware as the master branch changed quite a lot during that time, I suggest to start again from the last master version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants