diff --git a/packages/rocketchat-ui/lib/iframeCommands.js b/packages/rocketchat-ui/lib/iframeCommands.js index 4e74ca1ff5a..5ff57ff1807 100644 --- a/packages/rocketchat-ui/lib/iframeCommands.js +++ b/packages/rocketchat-ui/lib/iframeCommands.js @@ -19,12 +19,17 @@ const commands = { }, event.origin); }; - if (typeof data.service === 'string') { + const siteUrl = Meteor.settings.Site_Url + '/'; + if (typeof data.redirectUrl !== 'string' || !data.redirectUrl.startsWith(siteUrl)) { + data.redirectUrl = null; + } + + if (typeof data.service === 'string' && window.ServiceConfiguration) { const customOauth = ServiceConfiguration.configurations.findOne({service: data.service}); if (customOauth) { const customLoginWith = Meteor['loginWith' + _.capitalize(customOauth.service, true)]; - const customRedirectUri = window.OAuth._redirectUri(customOauth.service, customOauth); + const customRedirectUri = data.redirectUrl || siteUrl; customLoginWith.call(Meteor, {'redirectUrl': customRedirectUri}, customOAuthCallback); } }