mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
[PUI] Fix logout (#6284)
* fix path * changed PUI to use logout route Fixes #5968
This commit is contained in:
parent
64dbf8c1e3
commit
357f715789
@ -2,7 +2,7 @@
|
||||
|
||||
from django.conf import settings
|
||||
from django.shortcuts import redirect
|
||||
from django.urls import include, path
|
||||
from django.urls import include, path, re_path
|
||||
from django.views.decorators.csrf import ensure_csrf_cookie
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
@ -31,7 +31,7 @@ urlpatterns = [
|
||||
spa_view,
|
||||
name='password_reset_confirm',
|
||||
),
|
||||
path('', spa_view),
|
||||
re_path('.*', spa_view),
|
||||
]),
|
||||
),
|
||||
assets_path,
|
||||
|
@ -13,5 +13,10 @@ export function setApiDefaults() {
|
||||
|
||||
api.defaults.baseURL = host;
|
||||
api.defaults.headers.common['Authorization'] = `Token ${token}`;
|
||||
|
||||
// CSRF support (needed for POST, PUT, PATCH, DELETE)
|
||||
api.defaults.withCredentials = true;
|
||||
api.defaults.xsrfCookieName = 'csrftoken';
|
||||
api.defaults.xsrfHeaderName = 'X-CSRFToken';
|
||||
}
|
||||
export const queryClient = new QueryClient();
|
||||
|
@ -19,6 +19,7 @@ export enum ApiPaths {
|
||||
user_email_verify = 'api-user-email-verify',
|
||||
user_email_primary = 'api-user-email-primary',
|
||||
user_email_remove = 'api-user-email-remove',
|
||||
user_logout = 'api-user-logout',
|
||||
|
||||
user_list = 'api-user-list',
|
||||
group_list = 'api-group-list',
|
||||
|
@ -48,7 +48,9 @@ export const doClassicLogin = async (username: string, password: string) => {
|
||||
* Logout the user (invalidate auth token)
|
||||
*/
|
||||
export const doClassicLogout = async () => {
|
||||
// TODO @matmair - logout from the server session
|
||||
// Logout from the server session
|
||||
await api.post(apiUrl(ApiPaths.user_logout));
|
||||
|
||||
// Set token in context
|
||||
const { setToken } = useSessionState.getState();
|
||||
setToken(undefined);
|
||||
|
@ -95,6 +95,8 @@ export function apiEndpoint(path: ApiPaths): string {
|
||||
return 'auth/emails/:id/verify/';
|
||||
case ApiPaths.user_email_primary:
|
||||
return 'auth/emails/:id/primary/';
|
||||
case ApiPaths.user_logout:
|
||||
return 'auth/logout/';
|
||||
case ApiPaths.currency_list:
|
||||
return 'currency/exchange/';
|
||||
case ApiPaths.currency_refresh:
|
||||
|
Loading…
Reference in New Issue
Block a user