diff --git a/.changeset/sharp-beers-search.md b/.changeset/sharp-beers-search.md new file mode 100644 index 0000000000000..0b674b3318eec --- /dev/null +++ b/.changeset/sharp-beers-search.md @@ -0,0 +1,5 @@ +--- +"@rocket.chat/meteor": major +--- + +Removes the deprecated `insertOrUpdateUser` meteor method diff --git a/apps/meteor/app/lib/server/index.ts b/apps/meteor/app/lib/server/index.ts index be3dee2611cde..551fd20e2545b 100644 --- a/apps/meteor/app/lib/server/index.ts +++ b/apps/meteor/app/lib/server/index.ts @@ -28,7 +28,6 @@ import './methods/getMessages'; import './methods/getSlashCommandPreviews'; import './methods/getUsernameSuggestion'; import './methods/getUserRoles'; -import './methods/insertOrUpdateUser'; import './methods/joinDefaultChannels'; import './methods/joinRoom'; import './methods/leaveRoom'; diff --git a/apps/meteor/app/lib/server/methods/insertOrUpdateUser.ts b/apps/meteor/app/lib/server/methods/insertOrUpdateUser.ts deleted file mode 100644 index 7907d0e185ce6..0000000000000 --- a/apps/meteor/app/lib/server/methods/insertOrUpdateUser.ts +++ /dev/null @@ -1,32 +0,0 @@ -import type { ServerMethods } from '@rocket.chat/ddp-client'; -import { check } from 'meteor/check'; -import { Meteor } from 'meteor/meteor'; - -import { twoFactorRequired } from '../../../2fa/server/twoFactorRequired'; -import { saveUser } from '../functions/saveUser'; -import { methodDeprecationLogger } from '../lib/deprecationWarningLogger'; - -declare module '@rocket.chat/ddp-client' { - // eslint-disable-next-line @typescript-eslint/naming-convention - interface ServerMethods { - insertOrUpdateUser(userData: Record): Promise; - } -} - -Meteor.methods({ - insertOrUpdateUser: twoFactorRequired(async (userData) => { - methodDeprecationLogger.method('insertOrUpdateUser', '8.0.0', '/v1/users.create'); - - check(userData, Object); - - const userId = Meteor.userId(); - - if (!userId) { - throw new Meteor.Error('error-invalid-user', 'Invalid user', { - method: 'insertOrUpdateUser', - }); - } - - return saveUser(userId, userData); - }), -}); diff --git a/apps/meteor/tests/end-to-end/api/methods.ts b/apps/meteor/tests/end-to-end/api/methods.ts index 7a607e9a23d61..b9d99d9792aa0 100644 --- a/apps/meteor/tests/end-to-end/api/methods.ts +++ b/apps/meteor/tests/end-to-end/api/methods.ts @@ -3251,80 +3251,6 @@ describe('Meteor.methods', () => { }); }); - describe('@insertOrUpdateUser', () => { - let testUser: TestUser; - let testUserCredentials: Credentials; - - before(async () => { - testUser = await createUser(); - testUserCredentials = await login(testUser.username, password); - }); - - after(() => Promise.all([deleteUser(testUser)])); - - it('should fail if user tries to verify their own email via insertOrUpdateUser', (done) => { - void request - .post(methodCall('insertOrUpdateUser')) - .set(testUserCredentials) - .send({ - message: JSON.stringify({ - method: 'insertOrUpdateUser', - params: [ - { - _id: testUserCredentials['X-User-Id'], - email: 'manager@rocket.chat', - verified: true, - }, - ], - id: '52', - msg: 'method', - }), - }) - .expect('Content-Type', 'application/json') - .expect(200) - .expect((res) => { - expect(res.body).to.have.a.property('success', true); - expect(res.body).to.have.a.property('message').that.is.a('string'); - const data = JSON.parse(res.body.message); - expect(data).to.have.a.property('msg', 'result'); - expect(data).to.have.a.property('id', '52'); - expect(data.error).to.have.property('error', 'error-action-not-allowed'); - }) - .end(done); - }); - - it('should pass if a user with the right permissions tries to verify the email of another user', (done) => { - void request - .post(methodCall('insertOrUpdateUser')) - .set(credentials) - .send({ - message: JSON.stringify({ - method: 'insertOrUpdateUser', - params: [ - { - _id: testUserCredentials['X-User-Id'], - email: 'testuser@rocket.chat', - verified: true, - }, - ], - id: '52', - msg: 'method', - }), - }) - .expect('Content-Type', 'application/json') - .expect(200) - .expect((res) => { - expect(res.body).to.have.a.property('success', true); - expect(res.body).to.have.a.property('message').that.is.a('string'); - const data = JSON.parse(res.body.message); - expect(data).to.have.a.property('msg', 'result'); - expect(data).to.have.a.property('id', '52'); - expect(data).to.have.a.property('result', true); - }) - .end(done); - }); - }); - (IS_EE ? describe : describe.skip)('[@auditGetAuditions] EE', () => { let testUser: TestUser; let testUserCredentials: Credentials;