Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions src/backend/InvenTree/users/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,17 +435,26 @@ def get_object(self):


user_urls = [
path('roles/', RoleDetails.as_view(), name='api-user-roles'),
path('token/', ensure_csrf_cookie(GetAuthToken.as_view()), name='api-token'),
# Individual user endpoints
path(
'tokens/',
'me/',
include([
path('profile/', UserProfileDetail.as_view(), name='api-user-profile'),
path('roles/', RoleDetails.as_view(), name='api-user-roles'),
path(
'token/', ensure_csrf_cookie(GetAuthToken.as_view()), name='api-token'
),
path('', MeUserDetail.as_view(), name='api-user-me'),
]),
),
# User related endpoints
path(
'token/',
include([
path('<int:pk>/', TokenDetailView.as_view(), name='api-token-detail'),
path('', TokenListView.as_view(), name='api-token-list'),
]),
),
path('me/', MeUserDetail.as_view(), name='api-user-me'),
path('profile/', UserProfileDetail.as_view(), name='api-user-profile'),
path(
'owner/',
include([
Expand All @@ -467,6 +476,7 @@ def get_object(self):
path('', RuleSetList.as_view(), name='api-ruleset-list'),
]),
),
# General user endpoints
path('<int:pk>/', UserDetail.as_view(), name='api-user-detail'),
path('', UserList.as_view(), name='api-user-list'),
]
11 changes: 6 additions & 5 deletions src/frontend/lib/enums/ApiEndpoints.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ export enum ApiEndpoints {

// User API endpoints
user_list = 'user/',
user_me = 'user/me/',
user_profile = 'user/profile/',
user_roles = 'user/roles/',
user_token = 'user/token/',
user_tokens = 'user/tokens/',
user_tokens = 'user/token/',
user_simple_login = 'email/generate/',
// Individual user endpoints
user_me_profile = 'user/me/profile/',
user_me_roles = 'user/me/roles/',
user_me_token = 'user/me/token/',
user_me = 'user/me/',

// User auth endpoints
user_reset = 'auth/v1/auth/password/request',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export function AccountDetailPanel() {

const editProfile = useEditApiFormModal({
title: t`Edit Profile Information`,
url: ApiEndpoints.user_profile,
url: ApiEndpoints.user_me_profile,
onFormSuccess: fetchUserState,
fields: profileFields,
successMessage: t`Profile details updated`
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/states/LocalState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ pushes changes in user profile to backend
function patchUser(key: 'language' | 'theme' | 'widgets', val: any) {
const uid = useUserState.getState().userId();
if (uid) {
api.patch(apiUrl(ApiEndpoints.user_profile), { [key]: val });
api.patch(apiUrl(ApiEndpoints.user_me_profile), { [key]: val });
} else {
console.log('user not logged in, not patching');
}
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/states/UserState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export const useUserState = create<UserStateProps>((set, get) => ({

// Fetch role data
await api
.get(apiUrl(ApiEndpoints.user_roles))
.get(apiUrl(ApiEndpoints.user_me_roles))
.then((response) => {
if (response.status == 200) {
const user: UserProps = get().user as UserProps;
Expand Down
Loading