From d1571e51d99ead8f481ccd2b4039f8b750db21eb Mon Sep 17 00:00:00 2001 From: dougfabris Date: Wed, 23 Aug 2023 20:52:42 -0300 Subject: [PATCH 1/3] fix: missing params --- apps/meteor/app/api/server/v1/users.ts | 13 +++---------- packages/rest-typings/src/v1/users.ts | 16 +++------------- .../users/UsersUpdateOwnBasicInfoParamsPOST.ts | 11 ++++++++--- 3 files changed, 14 insertions(+), 26 deletions(-) diff --git a/apps/meteor/app/api/server/v1/users.ts b/apps/meteor/app/api/server/v1/users.ts index a4e3f974ac65..c4e4f5af26f8 100644 --- a/apps/meteor/app/api/server/v1/users.ts +++ b/apps/meteor/app/api/server/v1/users.ts @@ -126,20 +126,13 @@ API.v1.addRoute( realname: this.bodyParams.data.name, username: this.bodyParams.data.username, nickname: this.bodyParams.data.nickname, + bio: this.bodyParams.data.bio, statusText: this.bodyParams.data.statusText, + statusType: this.bodyParams.data.statusType, newPassword: this.bodyParams.data.newPassword, - typedPassword: this.bodyParams.data.currentPassword, }; - // saveUserProfile now uses the default two factor authentication procedures, so we need to provide that - const twoFactorOptions = !userData.typedPassword - ? null - : { - twoFactorCode: userData.typedPassword, - twoFactorMethod: 'password', - }; - - await Meteor.callAsync('saveUserProfile', userData, this.bodyParams.customFields, twoFactorOptions); + await Meteor.callAsync('saveUserProfile', userData, this.bodyParams.customFields); return API.v1.success({ user: await Users.findOneById(this.userId, { projection: API.v1.defaultFieldsToExclude }), diff --git a/packages/rest-typings/src/v1/users.ts b/packages/rest-typings/src/v1/users.ts index 947228476bdd..c47f4be6404d 100644 --- a/packages/rest-typings/src/v1/users.ts +++ b/packages/rest-typings/src/v1/users.ts @@ -9,7 +9,6 @@ import type { } from '@rocket.chat/core-typings'; import Ajv from 'ajv'; -import type { UsersSendConfirmationEmailParamsPOST } from '..'; import type { PaginatedRequest } from '../helpers/PaginatedRequest'; import type { PaginatedResult } from '../helpers/PaginatedResult'; import type { UserCreateParamsPOST } from './users/UserCreateParamsPOST'; @@ -20,7 +19,9 @@ import type { UserSetActiveStatusParamsPOST } from './users/UserSetActiveStatusP import type { UsersAutocompleteParamsGET } from './users/UsersAutocompleteParamsGET'; import type { UsersInfoParamsGet } from './users/UsersInfoParamsGet'; import type { UsersListTeamsParamsGET } from './users/UsersListTeamsParamsGET'; +import type { UsersSendConfirmationEmailParamsPOST } from './users/UsersSendConfirmationEmailParamsPOST'; import type { UsersSetPreferencesParamsPOST } from './users/UsersSetPreferenceParamsPOST'; +import type { UsersUpdateOwnBasicInfoParamsPOST } from './users/UsersUpdateOwnBasicInfoParamsPOST'; import type { UsersUpdateParamsPOST } from './users/UsersUpdateParamsPOST'; const ajv = new Ajv({ @@ -358,18 +359,7 @@ export type UsersEndpoints = { }; '/v1/users.updateOwnBasicInfo': { - POST: (params: { - data: { - email?: string; - name?: string; - username?: string; - nickname?: string; - statusText?: string; - newPassword?: string; - currentPassword?: string; - }; - customFields?: Record; - }) => { + POST: (params: UsersUpdateOwnBasicInfoParamsPOST) => { user: IUser; }; }; diff --git a/packages/rest-typings/src/v1/users/UsersUpdateOwnBasicInfoParamsPOST.ts b/packages/rest-typings/src/v1/users/UsersUpdateOwnBasicInfoParamsPOST.ts index cff6fee56bfa..c53d3313c8f3 100644 --- a/packages/rest-typings/src/v1/users/UsersUpdateOwnBasicInfoParamsPOST.ts +++ b/packages/rest-typings/src/v1/users/UsersUpdateOwnBasicInfoParamsPOST.ts @@ -10,8 +10,9 @@ export type UsersUpdateOwnBasicInfoParamsPOST = { name?: string; username?: string; nickname?: string; + bio?: string; statusText?: string; - currentPassword?: string; + statusType?: string; newPassword?: string; }; customFields?: Record; @@ -39,11 +40,15 @@ const UsersUpdateOwnBasicInfoParamsPostSchema = { type: 'string', nullable: true, }, - statusText: { + bio: { type: 'string', nullable: true, }, - currentPassword: { + statusType: { + type: 'string', + nullable: true, + }, + statusText: { type: 'string', nullable: true, }, From dc6fdba09bf7914b76d5781e7b329ecbb3d7865a Mon Sep 17 00:00:00 2001 From: dougfabris Date: Fri, 8 Sep 2023 14:56:48 -0300 Subject: [PATCH 2/3] chore: fix review --- apps/meteor/app/api/server/v1/users.ts | 11 ++++++++++- .../src/v1/users/UsersUpdateOwnBasicInfoParamsPOST.ts | 5 +++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/apps/meteor/app/api/server/v1/users.ts b/apps/meteor/app/api/server/v1/users.ts index c4e4f5af26f8..b23d41255c3b 100644 --- a/apps/meteor/app/api/server/v1/users.ts +++ b/apps/meteor/app/api/server/v1/users.ts @@ -130,9 +130,18 @@ API.v1.addRoute( statusText: this.bodyParams.data.statusText, statusType: this.bodyParams.data.statusType, newPassword: this.bodyParams.data.newPassword, + typedPassword: this.bodyParams.data.currentPassword, }; - await Meteor.callAsync('saveUserProfile', userData, this.bodyParams.customFields); + // saveUserProfile now uses the default two factor authentication procedures, so we need to provide that + const twoFactorOptions = !userData.typedPassword + ? null + : { + twoFactorCode: userData.typedPassword, + twoFactorMethod: 'password', + }; + + await Meteor.callAsync('saveUserProfile', userData, this.bodyParams.customFields, twoFactorOptions); return API.v1.success({ user: await Users.findOneById(this.userId, { projection: API.v1.defaultFieldsToExclude }), diff --git a/packages/rest-typings/src/v1/users/UsersUpdateOwnBasicInfoParamsPOST.ts b/packages/rest-typings/src/v1/users/UsersUpdateOwnBasicInfoParamsPOST.ts index c53d3313c8f3..13c3066e4767 100644 --- a/packages/rest-typings/src/v1/users/UsersUpdateOwnBasicInfoParamsPOST.ts +++ b/packages/rest-typings/src/v1/users/UsersUpdateOwnBasicInfoParamsPOST.ts @@ -13,6 +13,7 @@ export type UsersUpdateOwnBasicInfoParamsPOST = { bio?: string; statusText?: string; statusType?: string; + currentPassword?: string; newPassword?: string; }; customFields?: Record; @@ -52,6 +53,10 @@ const UsersUpdateOwnBasicInfoParamsPostSchema = { type: 'string', nullable: true, }, + currentPassword: { + type: 'string', + nullable: true, + }, newPassword: { type: 'string', nullable: true, From 988a52d1bd31d6c4ca9fae688e1cd586384cef6f Mon Sep 17 00:00:00 2001 From: dougfabris Date: Mon, 11 Sep 2023 11:06:02 -0300 Subject: [PATCH 3/3] chore: changeset --- .changeset/wise-walls-tan.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/wise-walls-tan.md diff --git a/.changeset/wise-walls-tan.md b/.changeset/wise-walls-tan.md new file mode 100644 index 000000000000..f558de82ec4c --- /dev/null +++ b/.changeset/wise-walls-tan.md @@ -0,0 +1,6 @@ +--- +'@rocket.chat/rest-typings': minor +'@rocket.chat/meteor': minor +--- + +fix: missing params on updateOwnBasicInfo endpoint