Skip to content
Snippets Groups Projects
Commit 3e6f24f5 authored by Pierre H. Lehnen's avatar Pierre H. Lehnen Committed by Diego Sampaio
Browse files

[FIX] Wordpress OAuth not providing enough info to log in (#11152)

parent 85b662b7
No related branches found
No related tags found
No related merge requests found
......@@ -35,7 +35,7 @@ RocketChat.API.v1.addRoute('settings.oauth', { authRequired: false }, {
const oAuthServicesEnabled = ServiceConfiguration.configurations.find({}, { fields: { secret: 0 } }).fetch();
return oAuthServicesEnabled.map((service) => {
if (service.custom || ['saml', 'cas'].includes(service.service)) {
if (service.custom || ['saml', 'cas', 'wordpress'].includes(service.service)) {
return { ...service };
}
......
......@@ -13,7 +13,7 @@ const config = {
const WordPress = new CustomOAuth('wordpress', config);
const fillSettings = _.debounce(() => {
const fillSettings = _.debounce(Meteor.bindEnvironment(() => {
config.serverURL = RocketChat.settings.get('API_Wordpress_URL');
delete config.identityPath;
......@@ -46,18 +46,34 @@ const fillSettings = _.debounce(() => {
}
break;
case 'wordpress-com':
config.identityPath = '/rest/v1/me';
config.identityPath = 'https://public-api.wordpress.com/rest/v1/me';
config.identityTokenSentVia = 'header';
config.authorizePath = '/oauth2/authorize';
config.tokenPath = '/oauth2/token';
config.authorizePath = 'https://public-api.wordpress.com/oauth2/authorize';
config.tokenPath = 'https://public-api.wordpress.com/oauth2/token';
config.scope = 'auth';
break;
default:
config.identityPath = '/oauth/me';
break;
}
return WordPress.configure(config);
}, 1000);
const result = WordPress.configure(config);
const enabled = RocketChat.settings.get('Accounts_OAuth_Wordpress');
if (enabled) {
ServiceConfiguration.configurations.upsert({
service: 'wordpress'
}, {
$set: config
});
} else {
ServiceConfiguration.configurations.remove({
service: 'wordpress'
});
}
return result;
}), 1000);
if (Meteor.isServer) {
Meteor.startup(function() {
......
......@@ -39,7 +39,8 @@ RocketChat.settings.addGroup('OAuth', function() {
key: 'custom',
i18nLabel: 'Accounts_OAuth_Wordpress_server_type_custom'
}
]
],
i18nLabel: 'Server_Type'
});
const customOAuthQuery = [{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment