Skip to content

Commit

Permalink
allow to call custom oauth services using iframe events, refs #4685 (#…
Browse files Browse the repository at this point in the history
…4687)

* allow to call custom oauth services using iframe events, refs #4685

* Remove console.log to complete pull-request 4687
  • Loading branch information
fabiomontefuscolo authored and rodrigok committed Oct 24, 2016
1 parent 0bba3eb commit a696c1e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/rocketchat-ui/lib/fireEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,24 @@ window.addEventListener('message', (e) => {
}
FlowRouter.go(e.data.path);
break;

case 'call-custom-oauth-login':
const customOAuthCallback = (response) => {
e.source.postMessage({
event: 'custom-oauth-callback',
response: response
}, e.origin);
};

if (typeof e.data.service === 'string') {
const customOauth = ServiceConfiguration.configurations.findOne({service: e.data.service});

if (customOauth) {
const customLoginWith = Meteor['loginWith' + _.capitalize(customOauth.service, true)];
const customRedirectUri = window.OAuth._redirectUri(customOauth.service, customOauth);
customLoginWith.call(Meteor, {'redirectUrl': customRedirectUri}, customOAuthCallback);
}
}
break;
}
});

0 comments on commit a696c1e

Please sign in to comment.