Social authentication in pop-up window - but how do I close it?
I'm planning to have the following functionality -
1. User clicks on social login button.
2. A pop-up window opens, which shows social authentication screen (viz. FB, Google, LinkedIn)
3. User logs in and allows the app to access data.
4. Gets redirected to the main app - at which point, the main browser window refreshes and the pop-up closes automatically.
I've been able to get the functionality working till point 4 but only till redirect. I've no clue how to close the pop-up window after it's redirected the user. Here's my code
- $(document).on('click', '.socialLoginButton', function(e) {
- e.preventDefault();
- let provider = $(this).attr('data-content');
- let left = ($(window).width() / 2) - (900 / 2),
- top = ($(window).height() / 2) - (600 / 2);
- let popup = window.open("/login/"+provider, "popup", "width=900, height=600, top=" + top + ", left=" + left);
- popup.redirectEnd.close(); // <--- This won't work.
- });
Would really appreciate if someone could show me a way to achieve this.
PS: Also wish to know if pop-up, in general is a good approach. I'm not sure how does browser decide when to block pop-ups and when to allow them.
I thank this wonderful community and look forward to receiving some help.