I'm following this instruction from another thread. Simple example of popup. The problem is I cant make it work on my Laravel app. I'm not quite knowledgeable about cookie and I'm not sure what to do with $('#UserInfo').text($.cookie("some_cookie"));
in the code.
I have made the facebook login to popup. The problem is that when I was successfully logged-in, It wont close the popup instead, it loads the redirect path to it.
I want to close the popup window once successfully logged in and then load the next route to the parent.
<input id="btn-facebook" type="button" value="Connect with Facebook" />
<script src="{{ asset('js/jquery.cookie.js') }}"></script>
<script>
var signinWin;
$('#btn-facebook').click(function () {
// var pos = screenCenterPos(800, 500);
signinWin = window.open("{!!URL::to('facebook')!!}", "SignIn", "width=780,height=410,toolbar=0,scrollbars=0,status=0,resizable=0,location=0,menuBar=0,left=" + 500 + ",top=" + 200);
setTimeout(CheckLoginStatus, 2000);
signinWin.focus();
return false;
});
function CheckLoginStatus() {
if (signinWin.closed) {
$('#UserInfo').text($.cookie("some_cookie"));
}
else setTimeout(CheckLoginStatus, 1000);
}
</script>
Laravel support social integration and has official packages. Socialite for Laravel
It has great documentation and excellent code sample.
For your problem. I'll try to explain what your code does:
First. You have a code that opens a new window
signinWin = window.open("{!!URL::to('facebook')!!}", "SignIn", "width=780,height=410,toolbar=0,scrollbars=0,status=0,resizable=0,location=0,menuBar=0,left=" + 500 + ",top=" + 200);
And a code that checks if the window is closed
if (signinWin.closed) {
This code $('#UserInfo').text($.cookie("some_cookie"));
only set text value to an element with ID of "UserInfo". It does not do a thing.
In order for the window to close you should add :
signinWin.close()
to your code. Or you code simply open the window in the same window by setting:
window.open("{!!URL::to('facebook')!!}", "_self", "width=780,height=410,toolbar=0,scrollbars=0,status=0,resizable=0,location=0,menuBar=0,left=" + 500 + ",top=" + 200);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With