diff --git a/.github/workflows/qc_checks.yaml b/.github/workflows/qc_checks.yaml index 985c0e213d7c..fb86ce8e4eca 100644 --- a/.github/workflows/qc_checks.yaml +++ b/.github/workflows/qc_checks.yaml @@ -215,7 +215,7 @@ jobs: run: echo "${DIFF}" >> $GITHUB_STEP_SUMMARY - name: Check for differences in API Schema - if: needs.paths-filter.outputs.api == 'false' + if: needs.paths-filter.outputs.api == 'false' && github.base_ref != 'next-breaking' run: | diff --color -u src/backend/InvenTree/schema.yml api.yaml diff -u src/backend/InvenTree/schema.yml api.yaml && echo "no difference in API schema " || exit 2 diff --git a/CHANGELOG.md b/CHANGELOG.md index c70ced72de2a..59af2f54e2f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Breaking Changes - Remove deprecated features and APIs +- [#9604](https://github.com/inventree/InvenTree/pull/9604) - refactors user API endpoint to be less ambiguous - [#11111](https://github.com/inventree/InvenTree/pull/11111) - removes legacy metadata APIs - [#9814](https://github.com/inventree/InvenTree/pull/9814) - removes legacy config path support - [#11667](https://github.com/inventree/InvenTree/pull/11667) - removes legacy url patterns diff --git a/src/backend/InvenTree/users/api.py b/src/backend/InvenTree/users/api.py index 42201ed09554..030031fa3315 100644 --- a/src/backend/InvenTree/users/api.py +++ b/src/backend/InvenTree/users/api.py @@ -506,17 +506,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('/', 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([ diff --git a/src/frontend/lib/enums/ApiEndpoints.tsx b/src/frontend/lib/enums/ApiEndpoints.tsx index e7adf3f0b8d0..26635e3a7abc 100644 --- a/src/frontend/lib/enums/ApiEndpoints.tsx +++ b/src/frontend/lib/enums/ApiEndpoints.tsx @@ -12,12 +12,13 @@ export enum ApiEndpoints { // User API endpoints user_list = 'user/', user_set_password = 'user/:id/set-password/', - 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 auth_base = '/auth/', diff --git a/src/frontend/src/pages/Index/Settings/AccountSettings/AccountDetailPanel.tsx b/src/frontend/src/pages/Index/Settings/AccountSettings/AccountDetailPanel.tsx index f879e7790682..062a73de7451 100644 --- a/src/frontend/src/pages/Index/Settings/AccountSettings/AccountDetailPanel.tsx +++ b/src/frontend/src/pages/Index/Settings/AccountSettings/AccountDetailPanel.tsx @@ -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` diff --git a/src/frontend/src/states/LocalState.tsx b/src/frontend/src/states/LocalState.tsx index 869889439fb8..4519a59f11e7 100644 --- a/src/frontend/src/states/LocalState.tsx +++ b/src/frontend/src/states/LocalState.tsx @@ -165,7 +165,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'); } diff --git a/src/frontend/src/states/UserState.tsx b/src/frontend/src/states/UserState.tsx index 16cfd75bde73..f6e309861ac7 100644 --- a/src/frontend/src/states/UserState.tsx +++ b/src/frontend/src/states/UserState.tsx @@ -104,7 +104,7 @@ export const useUserState = create((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;