使用MVC 5 OWIN时从Facebook注销 [英] Logging out from facebook when using MVC 5 OWIN

查看:210
本文介绍了使用MVC 5 OWIN时从Facebook注销的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有了Facebook的身份验证设置和工作很好的MVC 5 Web应用程序。用户点击脸谱的登录页面上,标志到Facebook,并与我们的网站进行身份验证。如果用户注销时,调用AuthenticationManager.SignOut()注销该网站的正确,但如果用户然后返回到登录页面,并点击脸谱他们又立即无需登录到签署Facebook的。

I have an MVC 5 web app that has facebook authentication set up and working nicely. User clicks "Facebook" on the login page, signs in to Facebook and that authenticates with our web site. If the user logs out, the call to AuthenticationManager.SignOut() logs out of the web site correctly, but if the user then goes back to the login page and clicks "Facebook" again they are immediately signed in without having to sign in to facebook.

所以我的问题是,我该如何配置MVC 5 OWIN Facebook登录,使用户在注销Facebook的时,他们登出的网站,或者换一种说法,验证的prevent缓存下一个标志。我不希望用户的Facebook登录到被悄悄地缓存在情况下,他们与其他用户共享一个浏览器。

So my question is, how do I configure MVC 5 OWIN facebook login so that the user is signed out of facebook when they sign out of the web site, or to put it another way, prevent caching of the authentication for the next sign in. I don't want a users facebook login to be silently cached in case they are sharing a browser with other users.

推荐答案

我知道这样做的唯一方法是,以配合一个事件,您的注销按钮或链接,并使用的的Facebook的Javascript SDK 实际为您执行Facebook的注销。

The only way that I know to do this would be to tie an event to your log out button or link and use the Facebook Javascript SDK to actually perform the Facebook logout 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和控制逻辑的一点点应该提供您需要的结果。

You could actually use the confirm dialog to ask if they want to be signed out of Facebook as well. A confirm would mean yes, a not confirm would mean no, just sign me out of your site. Again, using the SDK and a little bit of control logic should provide the results you need.

这篇关于使用MVC 5 OWIN时从Facebook注销的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆