Skip to content

Instantly share code, notes, and snippets.

@Tenkir
Last active August 29, 2015 14:26
Show Gist options
  • Save Tenkir/ffe243b85ebb98e0910f to your computer and use it in GitHub Desktop.
Save Tenkir/ffe243b85ebb98e0910f to your computer and use it in GitHub Desktop.
Angular Oauth Popup Handling
this.socialLogin = function(provider) {
$window.$scope = $rootScope;
var url = urlBase + '/' + provider,
width = 1000,
height = 650,
top = (window.outerHeight - height) / 2,
left = (window.outerWidth - width) / 2,
interval = 1000;
var options = 'width=' + width + ',height=' + height + ',scrollbars=0,top=' + top + ',left=' + left;
var socialPopup = $window.open(url, 'Social Login', options);
// create an ever increasing interval to check a certain global value getting assigned in the popup
var i = $interval(function(){
interval += 500;
try {
// value is the user_id returned
if (socialPopup.value){
$interval.cancel(i);
socialPopup.close();
}
} catch(e){
console.error(e);
}
}, interval);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment