2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-12 18:15:40 +00:00

[PUI] Logout Fixes (#6318)

* Refactor method to extract token from request

* Reimplement error-report API endpoint

- Removed in previous commit - b8b3dfc90e
- Adds unit tests to ensure it doesn't happen again

* Adds custom logout view for API

- Ensure correct token gets deleted
- Our new custom token setup is incompatible with default dj-rest-auth
This commit is contained in:
Oliver
2024-01-22 23:07:35 +11:00
committed by GitHub
parent e7d926f983
commit ab921ccb31
4 changed files with 49 additions and 25 deletions

View File

@ -48,16 +48,17 @@ export const doClassicLogin = async (username: string, password: string) => {
* Logout the user (invalidate auth token)
*/
export const doClassicLogout = async () => {
// Set token in context
const { setToken } = useSessionState.getState();
setToken(undefined);
// Logout from the server session
await api.post(apiUrl(ApiPaths.user_logout));
// Set token in context
const { setToken } = useSessionState.getState();
setToken(undefined);
notifications.show({
title: t`Logout successful`,
message: t`See you soon.`,
message: t`You have been logged out`,
color: 'green',
icon: <IconCheck size="1rem" />
});