2
0
mirror of https://github.com/inventree/InvenTree.git synced 2026-06-12 11:38:47 +00:00

realign user API endpoints (#11963)

* realign user API endpoints to make it clearer which one are only applicable to the current user

* fix name

* bump api

* fix test

* fix reference

* fix test exception

* update ref

* reduce breakage

* re-add legacy urls till next `breaking`
This commit is contained in:
Matthias Mair
2026-05-22 01:44:24 +02:00
committed by GitHub
parent f27b9b5443
commit 9908870a81
12 changed files with 72 additions and 17 deletions
+5 -4
View File
@@ -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_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/',
@@ -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`
+1 -1
View File
@@ -154,7 +154,7 @@ pushes changes in user profile to backend
export 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');
}
+1 -1
View File
@@ -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;
@@ -26,7 +26,7 @@ export function ApiTokenTable({
const [opened, { open, close }] = useDisclosure(false);
const generateToken = useCreateApiFormModal({
url: ApiEndpoints.user_token,
url: ApiEndpoints.user_me_token,
method: 'GET',
title: t`Generate Token`,
fields: { name: {} },
+1 -1
View File
@@ -70,7 +70,7 @@ export const test = baseTest.extend({
!msg.text().includes('/this/does/not/exist.js') &&
!url.includes('/this/does/not/exist.js') &&
!url.includes('/api/user/me/') &&
!url.includes('/api/user/token/') &&
!url.includes('/api/user/me/token/') &&
!url.includes('/api/auth/v1/auth/login') &&
!url.includes('/api/auth/v1/auth/session') &&
!url.includes('/api/auth/v1/account/authenticators/totp') &&
@@ -142,7 +142,7 @@ test('Dashboard - Preserve widget sizes', async ({ browser }) => {
password: user.testcred
});
(await api).patch('user/profile/', {
(await api).patch('user/me/profile/', {
data: {
widgets: {
widgets: ['ovr-so'],