Facebook logout using MVC 5 OWIN

I have an MVC 5 web application that has facebook authentication and works beautifully. The user clicks โ€œFacebookโ€ on the login page, subscribes to Facebook and authenticates to our website. If the user logs out, calling AuthenticationManager.SignOut () logs out of the website correctly, but if the user then returns to the login page and clicks the Facebook button again, they immediately sign up without having to log in to facebook.

So my question is how to configure MVC 5 OWIN facebook login so that the user will be signed out of facebook when they exit the website or, in another way, prevent authentication caching for the next login. I do not want the facebook login user to be quietly cached if they share the browser with other users.

+3
source share
4 answers

The only way I know is to associate the event with an exit button or link and use the Facebook Javascript SDK to actually log out to Facebook for you.

<a href="/Account/Logout" id="Logout">LogOut</a>

<script type="text/javascript">
   $(function(){
      $("#Logout").on("click", function(e){
        if(confirm("This will also log you out of Facebook.  Proceed?")){
           FB.logout(function(response) {
           // Person is now logged out
           });
         }else{ 
            //do not allow the link to continue and sign our of your site.
            //This is optional and allows you to provide options
            e.PreventDefault();
         }
      });    
   });
</script>

, , Facebook. , , , , . , SDK .

+1

. cookie, facebook.com, : cookie . Facebook . . Facebook, Facebook . , , Facebook.

Facebook ( , , , ). , , - CSRF, , , .

0

, .

"Code! MVC 5 App Facebook, Twitter, LinkedIn Google OAuth2 Sign-on" Microsoft :

Facebook, Facebook ( ), Facebook, . , Facebook Facebook. . , , .

, .

OWIN, :

You have more links to share, but drats, reputation is not high enough yet. :)

0
source

It was two years old, and if OpenID Connect is used, then the solution exists as

// POST: /Account/LogOff
    [HttpPost]
    [ValidateAntiForgeryToken]
    public ActionResult LogOff()
    {
        Request.GetOwinContext().Authentication.SignOut();
        return Redirect("/");
        //AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
        //return RedirectToAction("Index", "Home");
    }
0
source

All Articles