新增AuthenticationHelper认证助手,登录之后记录登录信息可用ClaimsPrincipal当事人(持证者)方式。登录注销均可异步

This commit is contained in:
xxred
2018-07-16 01:47:27 +08:00
parent 7fcb6d9450
commit 696959d7d4
7 changed files with 225 additions and 17 deletions
@@ -115,7 +115,8 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
/// <returns></returns>
public IActionResult Logout()
{
Admin.ClearInfo();
//Admin.ClearInfo();
Admin.ClearInfoAsync().Wait();
return Redirect("~/AdminCP/Login");
}
#endregion
+5
View File
@@ -23,6 +23,7 @@ using Senparc.CO2NET.RegisterServices;
using Senparc.Weixin;
using Senparc.CO2NET.Cache;
using System.Configuration;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.Extensions.Options;
using Senparc.Weixin.RegisterServices;
@@ -77,6 +78,9 @@ namespace COMCMS.Web
});
services.AddSenparcGlobalServices(Configuration)//Senparc.CO2NET 全局注册
.AddSenparcWeixinServices(Configuration);//Senparc.Weixin 注册(如果使用Senparc.Weixin SDK则添加)
//注册Cookie认证服务
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@@ -108,6 +112,7 @@ namespace COMCMS.Web
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseCookiePolicy();
app.UseAuthentication();
app.UseStaticHttpContext();
app.UseMvc(routes =>
+2 -2
View File
@@ -13,11 +13,11 @@
},
"connectionStrings": {
"dbconn": {
"connectionString": "Server=.;Port=3306;Database=comcms2;Uid=root;Pwd=root;SslMode=None",
"connectionString": "Server=.;Port=3306;Database=comcms2;Uid=root;Pwd=123456;SslMode=None",
"providerName": "MySql.Data.MySqlClient"
},
"mssqlconnon": {
"connectionString": "server=(local);database=comcmscore;uid=sa;pwd=123456",
"connectionString": "server=.\\SQLEXPRESS;database=comcmscore;uid=sa;pwd=123456",
"providerName": "System.Data.SqlClient"
}
}