From 46401ae13b2fa3b0b5cfd393ec6a6ba438daf062 Mon Sep 17 00:00:00 2001 From: yash-rajpal Date: Mon, 18 May 2026 12:18:45 +0530 Subject: [PATCH 1/3] wordpress custom OAuth --- apps/meteor/app/wordpress/server/lib.ts | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/apps/meteor/app/wordpress/server/lib.ts b/apps/meteor/app/wordpress/server/lib.ts index 7777ea1382215..279d70791e98f 100644 --- a/apps/meteor/app/wordpress/server/lib.ts +++ b/apps/meteor/app/wordpress/server/lib.ts @@ -1,12 +1,12 @@ -import type { OauthConfig } from '@rocket.chat/core-typings'; +import type { OAuthConfiguration } from '@rocket.chat/core-typings'; import { Meteor } from 'meteor/meteor'; import { ServiceConfiguration } from 'meteor/service-configuration'; import _ from 'underscore'; -import { CustomOAuth } from '../../custom-oauth/server/custom_oauth_server'; +import { addPassportCustomOAuth } from '../../../server/lib/oauth/addPassportCustomOAuth'; import { settings } from '../../settings/server'; -const config: OauthConfig = { +const config: Partial = { serverURL: '', identityPath: '/oauth/me', @@ -17,8 +17,6 @@ const config: OauthConfig = { accessTokenParam: 'access_token', }; -const WordPress = new CustomOAuth('wordpress', config); - const fillSettings = _.debounce(async (): Promise => { config.serverURL = settings.get('API_Wordpress_URL'); if (!config.serverURL) { @@ -28,12 +26,6 @@ const fillSettings = _.debounce(async (): Promise => { return; } - delete config.identityPath; - delete config.identityTokenSentVia; - delete config.authorizePath; - delete config.tokenPath; - delete config.scope; - const serverType = settings.get('Accounts_OAuth_Wordpress_server_type'); switch (serverType) { case 'custom': @@ -59,7 +51,7 @@ const fillSettings = _.debounce(async (): Promise => { break; case 'wordpress-com': config.identityPath = 'https://public-api.wordpress.com/rest/v1/me'; - config.identityTokenSentVia = 'header'; + config.identityTokenSentVia = 'header' as OAuthConfiguration['identityTokenSentVia']; config.authorizePath = 'https://public-api.wordpress.com/oauth2/authorize'; config.tokenPath = 'https://public-api.wordpress.com/oauth2/token'; config.scope = 'auth'; @@ -69,7 +61,8 @@ const fillSettings = _.debounce(async (): Promise => { break; } - const result = WordPress.configure(config); + addPassportCustomOAuth('wordpress', config); + const enabled = settings.get('Accounts_OAuth_Wordpress'); if (enabled) { await ServiceConfiguration.configurations.upsertAsync( @@ -85,8 +78,6 @@ const fillSettings = _.debounce(async (): Promise => { service: 'wordpress', }); } - - return result; }, 1000); Meteor.startup(() => { From 876131247c0f8b7587642eba6a444fe9953a9995 Mon Sep 17 00:00:00 2001 From: yash-rajpal Date: Mon, 18 May 2026 22:05:45 +0530 Subject: [PATCH 2/3] cleanup --- apps/meteor/app/wordpress/server/lib.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/meteor/app/wordpress/server/lib.ts b/apps/meteor/app/wordpress/server/lib.ts index 279d70791e98f..e779d0225ff22 100644 --- a/apps/meteor/app/wordpress/server/lib.ts +++ b/apps/meteor/app/wordpress/server/lib.ts @@ -1,6 +1,7 @@ import type { OAuthConfiguration } from '@rocket.chat/core-typings'; import { Meteor } from 'meteor/meteor'; import { ServiceConfiguration } from 'meteor/service-configuration'; +import passport from 'passport'; import _ from 'underscore'; import { addPassportCustomOAuth } from '../../../server/lib/oauth/addPassportCustomOAuth'; @@ -17,7 +18,11 @@ const config: Partial = { accessTokenParam: 'access_token', }; +const serviceKey = 'wordpress'; + const fillSettings = _.debounce(async (): Promise => { + passport.unuse(serviceKey); + config.serverURL = settings.get('API_Wordpress_URL'); if (!config.serverURL) { if (config.serverURL === undefined) { @@ -61,13 +66,13 @@ const fillSettings = _.debounce(async (): Promise => { break; } - addPassportCustomOAuth('wordpress', config); + addPassportCustomOAuth(serviceKey, config); const enabled = settings.get('Accounts_OAuth_Wordpress'); if (enabled) { await ServiceConfiguration.configurations.upsertAsync( { - service: 'wordpress', + service: serviceKey, }, { $set: config, @@ -75,7 +80,7 @@ const fillSettings = _.debounce(async (): Promise => { ); } else { await ServiceConfiguration.configurations.removeAsync({ - service: 'wordpress', + service: serviceKey, }); } }, 1000); From 9d2b89d9cae213e5132acaa213d944a093fb5796 Mon Sep 17 00:00:00 2001 From: yash-rajpal Date: Tue, 19 May 2026 21:07:24 +0530 Subject: [PATCH 3/3] fix review --- apps/meteor/app/wordpress/server/lib.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/meteor/app/wordpress/server/lib.ts b/apps/meteor/app/wordpress/server/lib.ts index e779d0225ff22..eb1ce2c01ceb2 100644 --- a/apps/meteor/app/wordpress/server/lib.ts +++ b/apps/meteor/app/wordpress/server/lib.ts @@ -21,8 +21,6 @@ const config: Partial = { const serviceKey = 'wordpress'; const fillSettings = _.debounce(async (): Promise => { - passport.unuse(serviceKey); - config.serverURL = settings.get('API_Wordpress_URL'); if (!config.serverURL) { if (config.serverURL === undefined) { @@ -31,6 +29,8 @@ const fillSettings = _.debounce(async (): Promise => { return; } + passport.unuse(serviceKey); + const serverType = settings.get('Accounts_OAuth_Wordpress_server_type'); switch (serverType) { case 'custom':