Repository navigation
[PUI] Login / Logout State Fixes - #6368
Conversation
- Create new global state manager - Load *after* login - Prevents auth popup dialog and failure messages
✅ Deploy Preview for inventree-web-pui-preview ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
matmair
left a comment
There was a problem hiding this comment.
LGTM; we will need to bump the API version
There are no longer any API changes in this PR :) |
- Using new get_token_from_request method
- return early
- track an internal flag in apiState
- Rename doClassicLogin to doBasicLogin (reflecting "basic" auth) - Add "loggedIn" attribute to sessionState - Cleanup procedure for securing a token
- Prevent failed calls to user_me
- Simpler to just track token state - No need for separate status tracker - Works much cleaner this way
|
Ok, it took me a while to be happy with this - I had been seeing lots of strange login / logout bugs up until now. I am pretty sure this is good now, but I'll leave open for you guys to check again, make sure we are all happy with it. |
- Account for the presence of a CSRF session cookie - If available, use it to fetch a token
- Forces logout from session - Tested, works well! - Clean up notifications
matmair
left a comment
There was a problem hiding this comment.
I have submitted a fix, now it works
|
@matmair this review process has made me question - is it a good idea to just use CSRF session auth for PUI (as we do for CUI) and not use API tokens at all? As far as I can see there are two major advantages: Session ManagementUsing a single session (based on CSRF token) means that CUI and PUI are in sync. No need to manage two separate login methods (session token / API token) as we do now. File DownloadsMoving to session auth would allow us to download files / reports / etc in the browser - a problem which is currently hard to solve with API tokens - see #5697 So, move to session token and this problem goes away (because the web session has the same token and we don't have to work out how to pass an API token to a file download). Thoughts on this? Now that we are deep in the weeds on this is the right time to do it. I'm just not sure how to get the CSRF token into the session when you login from PUI - we have to replicate the CUI behaviour... |
|
@SchrodingersGat that would be a possibility. I'm not 100% if it would work but it would be cleaner for sure. From my POV that would make more sense in a new PR as this is one is blocking #6333, which is blocking #6200 |
|
And a small technical nitpick: Session managment is handled via the session token, not the CSRF one - those are similar but different mechanics. |
|
Would a session-based management make SSO support easier, though? Should we consider this properly first before merging SSO, so that we don't have to potentially refactor that again anyway? |
SSO is already fully functional and done in #6333 - it works using the backend |
Login yes but full Django sessions use a separate cookie - see the offical docs. Authentication and Sessions are fully decoupled. |
|
Ok, so should I merge this in (so we can proceed with SSO) and then investigate session based login for PUI separately? |



Fixes some bugs related to state management and API queries.
This drastically improves the login/logout experience for platform UI