FB popup not back in the web main windows, but stay in the popup


Hi, I had ask a question on this link about how can minimize a full page login with facebook in just popup :

https://qawithexperts.com/questions/360/login-with-facebook-using-oauth-redirect-us-to-full-page-how

but this FB popup does not return to main windows, stay in the popup , I would like to have code which should return back login details in the main tab.

Right now, when logging using popup It is still inside popup & not redirected to the main tab.

not_back_to_main_windows-min.png

how can I resolve that problem. Thanks in advance.

 


Asked by:- LuneAgile
0
: 2784 At:- 9/12/2018 12:32:41 PM
ASP.NET Login-fb-with-pop-up







4 Answers
profileImage Answered by:- vikas_jk

You need to do create some custom Javascript based on your requirement, after successful login,

  • simply close the pop-up, you can do this using javascript(One login page success, execute js to close pop-up)
  • then navigate to next page in main tab, you can do this also using javascript (on pop-up closed, call js to check if user is succesfully logged in, if yes, then go to next page).

If you don't like the above idea, check this link to manually handle login flow

https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow/#checklogin

Here is some more related links

https://www.sammyk.me/best-practice-for-facebook-login-with-the-javascript-sdk-and-php-sdk-v4-1

https://stackoverflow.com/questions/9793373/how-to-open-facebook-login-dialog-in-the-same-window-instead-of-popup-window

Try to create login button using JS https://developers.facebook.com/docs/facebook-login/web

Remember, for custom requirements like this you need to create own customised code, as per your needs(client side or server side, depends on your needs)

 

 

0
At:- 9/12/2018 3:14:37 PM


profileImage Answered by:- LuneAgile

Hi, Vikas Thanks so much for your reply. but I need to do that with  asp.net mvc5 c# not implement login facebook with javascript SDK.

Here is the  login.js  that I was use  for success or failure  . Thanks. I Still have the issue.

/**
 * Simulates Single Page Application login response.
 * This would normally be inside a client controller.
 * @param {object} - The external login result containing success and name.
 */
function externalLoginComplete(result) {
    if (result.success) {
        // After successfull login, validation token will stop working (login with external provider will return server error).
        $("#socialLoginForm").html("");
        // Simulate templating engine update by re-writing a portion of the main page.
        $("#loginForm").html(
            "<h3>Congratulations, " + result.name + "!</h3>You logged in successfully. If we were using a templating engine we would update the auth state here to re-render the UI.");
    } else {
        // When login fails, validation token keeps working so login with external provider can be retried.
        $("#loginForm").html(
            "<h3>Login cancelled</h3>Normally you would ignore this since your app state was 'not authorized' and remained 'not authorized' but for this demo we want to indicate success and failure.");
    }
}

And here the popup.js 

/**
* Open a popup dialog with standard size.
* @param {string} name - Window name that can be used as a target for a POST form.
* @param {function} onClose - Handler that receives a copy of popup's 'result' window variable (must be serializable to JSON).
*/
function openPopup(name, onClose) {
    watchPopup(window.open(
        'about:blank',
        name,
        'width=400,height=400,location=0,color=blue,centerscreen=1,resizable=0,scrollbars=0,status=0,toolbar=0,menubar=0,personalbar=0',
        true), onClose);
}
/**
* Watches and closes a popup when it returns a result.
* @param {object} popup - Popup window.
* @param {function} onClose - Handler that receives a copy of popup's 'result' window variable.
*/
function watchPopup(popup, onClose) {
    if (popup) {
        if (watchPopup.watchTimer) {
            try {
                if (popup.closed) {
                    cancelPopup(popup, watchPopup.closeHandler)
                }
                if (popup.result) {
                    closePopup(popup, watchPopup.closeHandler);
                }
            }
            catch (e) { }
        } else {
            watchPopup.closeHandler = onClose;
            watchPopup.watchTimer = setInterval(
                watchPopup, 200, popup);
        }
    } else if (watchPopup.watchTimer) {
        clearInterval(watchPopup.watchTimer);
        watchPopup.watchTimer = null;
    }
}
/**
* Handles popup closure where no result is available.
* @param {object} popup - The popup that was closed.
* @param {function} onClose - Close handler.
*/
function cancelPopup(popup, onClose) {
    watchPopup(null);
    onClose({ success: false });
}
/**
* Handles popup dismissal to handle the result.
* @param {object} popup - The popup that was dismissed.
* @param {function} onClose - Close handler.
*/
function closePopup(popup, onClose) {
    watchPopup(null);
    onClose(popup.result);
    popup.close();
}

 Maybe should I add redirected to my main web using that js but still not know how. :(

Thanks.

0
At:- 9/12/2018 4:43:59 PM Updated at:- 9/12/2018 4:48:27 PM


profileImage Answered by:- LuneAgile

Thanks Vikas. for your efort.  I will try those links and give you feedback.

0
At:- 9/13/2018 1:43:16 PM






Login/Register to answer
Or
Register directly by posting answer/details

Full Name *

Email *




By posting your answer you agree on privacy policy & terms of use