From 542fae08f30676426ed1d809340da33e64606cfa Mon Sep 17 00:00:00 2001 From: Abhinav Kumar Date: Thu, 10 Oct 2024 01:19:44 +0530 Subject: [PATCH] chore!: remove deprecated method getPasswordPolicy (#33473) --- .changeset/heavy-apricots-wash.md | 5 +++ .../server/methods/getPasswordPolicy.ts | 37 ------------------- apps/meteor/server/methods/index.ts | 1 - 3 files changed, 5 insertions(+), 38 deletions(-) create mode 100644 .changeset/heavy-apricots-wash.md delete mode 100644 apps/meteor/server/methods/getPasswordPolicy.ts diff --git a/.changeset/heavy-apricots-wash.md b/.changeset/heavy-apricots-wash.md new file mode 100644 index 000000000000..fe0e221cfa43 --- /dev/null +++ b/.changeset/heavy-apricots-wash.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/meteor': major +--- + +Removes deprecated method `getPasswordPolicy`. Moving forward, use the endpoint `pw.getPolicy`. diff --git a/apps/meteor/server/methods/getPasswordPolicy.ts b/apps/meteor/server/methods/getPasswordPolicy.ts deleted file mode 100644 index 483938716093..000000000000 --- a/apps/meteor/server/methods/getPasswordPolicy.ts +++ /dev/null @@ -1,37 +0,0 @@ -import type { ServerMethods } from '@rocket.chat/ddp-client'; -import { Users } from '@rocket.chat/models'; -import type { TranslationKey } from '@rocket.chat/ui-contexts'; -import { check } from 'meteor/check'; -import { Meteor } from 'meteor/meteor'; - -import { passwordPolicy } from '../../app/lib/server'; -import { methodDeprecationLogger } from '../../app/lib/server/lib/deprecationWarningLogger'; - -declare module '@rocket.chat/ddp-client' { - // eslint-disable-next-line @typescript-eslint/naming-convention - interface ServerMethods { - getPasswordPolicy(params: { token: string }): { - enabled: boolean; - policy: [name: TranslationKey, options?: Record][]; - }; - } -} - -Meteor.methods({ - async getPasswordPolicy(params) { - methodDeprecationLogger.method('getPasswordPolicy', '7.0.0'); - - check(params, { token: String }); - - const user = await Users.findOne({ 'services.password.reset.token': params.token }); - if (!user && !Meteor.userId()) { - throw new Meteor.Error('error-invalid-user', 'Invalid user', { - method: 'getPasswordPolicy', - }); - } - return passwordPolicy.getPasswordPolicy() as { - enabled: boolean; - policy: [name: TranslationKey, options?: Record][]; - }; - }, -}); diff --git a/apps/meteor/server/methods/index.ts b/apps/meteor/server/methods/index.ts index 6ae87421c11a..dd738080e05d 100644 --- a/apps/meteor/server/methods/index.ts +++ b/apps/meteor/server/methods/index.ts @@ -13,7 +13,6 @@ import './createDirectMessage'; import './deleteFileMessage'; import './deleteUser'; import './getAvatarSuggestion'; -import './getPasswordPolicy'; import './getRoomById'; import './getRoomIdByNameOrId'; import './getRoomNameById';