Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 6 commits into from
Jun 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/rocketchat-api/server/v1/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}

Expand Down
28 changes: 22 additions & 6 deletions packages/rocketchat-wordpress/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down
3 changes: 2 additions & 1 deletion packages/rocketchat-wordpress/startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ RocketChat.settings.addGroup('OAuth', function() {
key: 'custom',
i18nLabel: 'Accounts_OAuth_Wordpress_server_type_custom'
}
]
],
i18nLabel: 'Server_Type'
});

const customOAuthQuery = [{
Expand Down