Skip to content

Conversation

melektron
Copy link

This PR fixes issue #10228.

PUI login via the /api/auth/login endpoint is handeled by a (modified) dj_rest_auth LoginView, which uses the TOKEN_CREATOR to get the token to return. The configured token creator users.models.create_token_expiry() doesn't account for expired tokens and returns the first matching token for the user, even if it may be expired.

In contrast, the users.api.GetAuthToken() view handles this correctly and creates a new token for authenticated users if no vaild token exists.

This is fixed by consolidating the logic for retrieving or creating an ApiToken into a single classmethod.

Copy link

netlify bot commented Aug 26, 2025

Deploy Preview for inventree-web-pui-preview ready!

Name Link
🔨 Latest commit 2d43539
🔍 Latest deploy log https://app.netlify.com/projects/inventree-web-pui-preview/deploys/68ad14556ac9d40008b2ba39
😎 Deploy Preview https://deploy-preview-10233--inventree-web-pui-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 99 (🟢 up 4 from production)
Accessibility: 86 (🟢 up 5 from production)
Best Practices: 92 (🔴 down 8 from production)
SEO: 78 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@melektron
Copy link
Author

I targeted this PR at stable as per the contribution guidelines for bugfixes, but this might apply to master as well.

Also, the GetAuthToken view I modified clearly states in the comments that it shouldn't return existing tokens, yet the previous implementation did (which I think makes sense). I kept the existing functionality in my change, should I modify/remove this comment?

Copy link

codecov bot commented Aug 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.31%. Comparing base (bca375d) to head (2d43539).
⚠️ Report is 6 commits behind head on 0.17.x.

Additional details and impacted files
@@            Coverage Diff             @@
##           0.17.x   #10233      +/-   ##
==========================================
- Coverage   84.31%   84.31%   -0.01%     
==========================================
  Files        1201     1201              
  Lines       54950    54951       +1     
  Branches     2115     2115              
==========================================
  Hits        46332    46332              
- Misses       8106     8107       +1     
  Partials      512      512              
Flag Coverage Δ
backend 86.12% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

@matmair
Copy link
Contributor

matmair commented Aug 26, 2025

Thank you for the submition @melektron ! This will not need a merge into current dev, we have removed dj_rest_auth

@SchrodingersGat SchrodingersGat changed the base branch from stable to 0.17.x September 1, 2025 23:34
@SchrodingersGat SchrodingersGat added this to the 0.17.15 milestone Sep 1, 2025
@SchrodingersGat SchrodingersGat merged commit c5ffb95 into inventree:0.17.x Sep 2, 2025
42 of 54 checks passed
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