From a68c2dedc6ce10923dfe6ef85c8b2d20fca3df4e Mon Sep 17 00:00:00 2001 From: Fabio Montefuscolo Date: Tue, 29 Nov 2016 16:29:19 -0200 Subject: [PATCH] fix redirectUrl after custom oauth successful login initiated by iframe command, fixes #5042 (#5043) --- packages/rocketchat-ui/lib/iframeCommands.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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); } }