mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -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()
|
@Expose()
|
||||||
@IsBoolean({ message: 'userActivated should be a boolean' })
|
@IsBoolean({ message: 'userActivated should be a boolean' })
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
userActivated: boolean;
|
userActivated?: boolean;
|
||||||
|
|
||||||
@Expose()
|
@Expose()
|
||||||
@IsBoolean({ message: 'allowSSOManualLogin should be a boolean' })
|
@IsBoolean({ message: 'allowSSOManualLogin should be a boolean' })
|
||||||
|
|
|
@ -5,9 +5,14 @@ import type {
|
||||||
IUserResponse,
|
IUserResponse,
|
||||||
InvitableRoleName,
|
InvitableRoleName,
|
||||||
} from '@/Interface';
|
} from '@/Interface';
|
||||||
import type { IDataObject } from 'n8n-workflow';
|
import type { IDataObject, IUserSettings } from 'n8n-workflow';
|
||||||
import { makeRestApiRequest } from '@/utils/apiUtils';
|
import { makeRestApiRequest } from '@/utils/apiUtils';
|
||||||
|
|
||||||
|
export interface IUpdateUserSettingsReqPayload {
|
||||||
|
allowSSOManualLogin?: boolean;
|
||||||
|
userActivated?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export async function loginCurrentUser(
|
export async function loginCurrentUser(
|
||||||
context: IRestApiContext,
|
context: IRestApiContext,
|
||||||
): Promise<CurrentUserResponse | null> {
|
): Promise<CurrentUserResponse | null> {
|
||||||
|
@ -93,27 +98,22 @@ export async function updateCurrentUser(
|
||||||
email: string;
|
email: string;
|
||||||
},
|
},
|
||||||
): Promise<IUserResponse> {
|
): Promise<IUserResponse> {
|
||||||
return await makeRestApiRequest(context, 'PATCH', '/me', params as unknown as IDataObject);
|
return await makeRestApiRequest(context, 'PATCH', '/me', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateCurrentUserSettings(
|
export async function updateCurrentUserSettings(
|
||||||
context: IRestApiContext,
|
context: IRestApiContext,
|
||||||
settings: IUserResponse['settings'],
|
settings: IUpdateUserSettingsReqPayload,
|
||||||
): Promise<IUserResponse['settings']> {
|
): Promise<IUserSettings> {
|
||||||
return await makeRestApiRequest(context, 'PATCH', '/me/settings', settings as IDataObject);
|
return await makeRestApiRequest(context, 'PATCH', '/me/settings', settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateOtherUserSettings(
|
export async function updateOtherUserSettings(
|
||||||
context: IRestApiContext,
|
context: IRestApiContext,
|
||||||
userId: string,
|
userId: string,
|
||||||
settings: IUserResponse['settings'],
|
settings: IUpdateUserSettingsReqPayload,
|
||||||
): Promise<IUserResponse['settings']> {
|
): Promise<IUserSettings> {
|
||||||
return await makeRestApiRequest(
|
return await makeRestApiRequest(context, 'PATCH', `/users/${userId}/settings`, settings);
|
||||||
context,
|
|
||||||
'PATCH',
|
|
||||||
`/users/${userId}/settings`,
|
|
||||||
settings as IDataObject,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateCurrentUserPassword(
|
export async function updateCurrentUserPassword(
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import type { UpdateGlobalRolePayload } from '@/api/users';
|
import type { IUpdateUserSettingsReqPayload, UpdateGlobalRolePayload } from '@/api/users';
|
||||||
import {
|
import {
|
||||||
changePassword,
|
changePassword,
|
||||||
deleteUser,
|
deleteUser,
|
||||||
|
@ -246,7 +246,7 @@ export const useUsersStore = defineStore(STORES.USERS, {
|
||||||
const user = await updateCurrentUser(rootStore.getRestApiContext, params);
|
const user = await updateCurrentUser(rootStore.getRestApiContext, params);
|
||||||
this.addUsers([user]);
|
this.addUsers([user]);
|
||||||
},
|
},
|
||||||
async updateUserSettings(settings: IUserResponse['settings']): Promise<void> {
|
async updateUserSettings(settings: IUpdateUserSettingsReqPayload): Promise<void> {
|
||||||
const rootStore = useRootStore();
|
const rootStore = useRootStore();
|
||||||
const updatedSettings = await updateCurrentUserSettings(
|
const updatedSettings = await updateCurrentUserSettings(
|
||||||
rootStore.getRestApiContext,
|
rootStore.getRestApiContext,
|
||||||
|
@ -259,7 +259,7 @@ export const useUsersStore = defineStore(STORES.USERS, {
|
||||||
},
|
},
|
||||||
async updateOtherUserSettings(
|
async updateOtherUserSettings(
|
||||||
userId: string,
|
userId: string,
|
||||||
settings: IUserResponse['settings'],
|
settings: IUpdateUserSettingsReqPayload,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const rootStore = useRootStore();
|
const rootStore = useRootStore();
|
||||||
const updatedSettings = await updateOtherUserSettings(
|
const updatedSettings = await updateOtherUserSettings(
|
||||||
|
|
Loading…
Reference in a new issue