mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -08:00
refactor: Update typings of /me/settings
and /users/:id/settings
endpoints (no-changelog) (#9620)
This commit is contained in:
parent
5322802992
commit
d6a046b8ad
|
@ -47,7 +47,7 @@ export class UserSettingsUpdatePayload {
|
|||
@Expose()
|
||||
@IsBoolean({ message: 'userActivated should be a boolean' })
|
||||
@IsOptional()
|
||||
userActivated: boolean;
|
||||
userActivated?: boolean;
|
||||
|
||||
@Expose()
|
||||
@IsBoolean({ message: 'allowSSOManualLogin should be a boolean' })
|
||||
|
|
|
@ -5,9 +5,14 @@ import type {
|
|||
IUserResponse,
|
||||
InvitableRoleName,
|
||||
} from '@/Interface';
|
||||
import type { IDataObject } from 'n8n-workflow';
|
||||
import type { IDataObject, IUserSettings } from 'n8n-workflow';
|
||||
import { makeRestApiRequest } from '@/utils/apiUtils';
|
||||
|
||||
export interface IUpdateUserSettingsReqPayload {
|
||||
allowSSOManualLogin?: boolean;
|
||||
userActivated?: boolean;
|
||||
}
|
||||
|
||||
export async function loginCurrentUser(
|
||||
context: IRestApiContext,
|
||||
): Promise<CurrentUserResponse | null> {
|
||||
|
@ -93,27 +98,22 @@ export async function updateCurrentUser(
|
|||
email: string;
|
||||
},
|
||||
): Promise<IUserResponse> {
|
||||
return await makeRestApiRequest(context, 'PATCH', '/me', params as unknown as IDataObject);
|
||||
return await makeRestApiRequest(context, 'PATCH', '/me', params);
|
||||
}
|
||||
|
||||
export async function updateCurrentUserSettings(
|
||||
context: IRestApiContext,
|
||||
settings: IUserResponse['settings'],
|
||||
): Promise<IUserResponse['settings']> {
|
||||
return await makeRestApiRequest(context, 'PATCH', '/me/settings', settings as IDataObject);
|
||||
settings: IUpdateUserSettingsReqPayload,
|
||||
): Promise<IUserSettings> {
|
||||
return await makeRestApiRequest(context, 'PATCH', '/me/settings', settings);
|
||||
}
|
||||
|
||||
export async function updateOtherUserSettings(
|
||||
context: IRestApiContext,
|
||||
userId: string,
|
||||
settings: IUserResponse['settings'],
|
||||
): Promise<IUserResponse['settings']> {
|
||||
return await makeRestApiRequest(
|
||||
context,
|
||||
'PATCH',
|
||||
`/users/${userId}/settings`,
|
||||
settings as IDataObject,
|
||||
);
|
||||
settings: IUpdateUserSettingsReqPayload,
|
||||
): Promise<IUserSettings> {
|
||||
return await makeRestApiRequest(context, 'PATCH', `/users/${userId}/settings`, settings);
|
||||
}
|
||||
|
||||
export async function updateCurrentUserPassword(
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import type { UpdateGlobalRolePayload } from '@/api/users';
|
||||
import type { IUpdateUserSettingsReqPayload, UpdateGlobalRolePayload } from '@/api/users';
|
||||
import {
|
||||
changePassword,
|
||||
deleteUser,
|
||||
|
@ -246,7 +246,7 @@ export const useUsersStore = defineStore(STORES.USERS, {
|
|||
const user = await updateCurrentUser(rootStore.getRestApiContext, params);
|
||||
this.addUsers([user]);
|
||||
},
|
||||
async updateUserSettings(settings: IUserResponse['settings']): Promise<void> {
|
||||
async updateUserSettings(settings: IUpdateUserSettingsReqPayload): Promise<void> {
|
||||
const rootStore = useRootStore();
|
||||
const updatedSettings = await updateCurrentUserSettings(
|
||||
rootStore.getRestApiContext,
|
||||
|
@ -259,7 +259,7 @@ export const useUsersStore = defineStore(STORES.USERS, {
|
|||
},
|
||||
async updateOtherUserSettings(
|
||||
userId: string,
|
||||
settings: IUserResponse['settings'],
|
||||
settings: IUpdateUserSettingsReqPayload,
|
||||
): Promise<void> {
|
||||
const rootStore = useRootStore();
|
||||
const updatedSettings = await updateOtherUserSettings(
|
||||
|
|
Loading…
Reference in a new issue