为什么在使用带有ASP.Net Identity的ApplicationCookie之前调用SignOut(DefaultAuthenticationTypes.ExternalCookie)?

 韩庚plus 发布于 2023-02-11 02:18

为什么这个示例在使用ApplicationCookie登录之前调用SignOut for ExternalCookie?它只是确保身份验证信息干净的一种方法吗?(完整的例子在这里:http://www.asp.net/identity/overview/getting-started/introduction-to-aspnet-identity)

private async Task SignInAsync(ApplicationUser user, bool isPersistent)
{
    AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);

    var identity = await UserManager.CreateIdentityAsync(
       user, DefaultAuthenticationTypes.ApplicationCookie);

    AuthenticationManager.SignIn(
       new AuthenticationProperties() { 
      IsPersistent = isPersistent 
       }, identity);
}

Hao Kung.. 9

它基本上是清理,外部cookie应该最终被清除,它只需要存储从google/fb/twitter等返回的声明,这样app可以在签署用户之前提取它需要的任何数据.所以SignIn是一个清除外部数据的好地方.

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有