Last active
August 29, 2015 14:26
-
-
Save Tenkir/ffe243b85ebb98e0910f to your computer and use it in GitHub Desktop.
Angular Oauth Popup Handling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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