优化登录用户权限缓存

This commit is contained in:
不做码农
2022-04-10 16:52:10 +08:00
parent 3eafab8292
commit 846652c1af
6 changed files with 51 additions and 42 deletions

View File

@@ -10,14 +10,6 @@ namespace ZR.Admin.WebApi.Extensions
{
var types = source.GetType();
//var worker = new IdWorker(1, 1);
//if (types.GetProperty("ID") != null)
//{
// long id = worker.NextId();
// types.GetProperty("ID").SetValue(source, id.ToString(), null);
//}
if (types.GetProperty("CreateTime") != null)
{
types.GetProperty("CreateTime").SetValue(source, DateTime.Now, null);
@@ -30,7 +22,6 @@ namespace ZR.Admin.WebApi.Extensions
{
types.GetProperty("UpdateTime").SetValue(source, DateTime.Now, null);
}
if (types.GetProperty("Create_by") != null && context != null)
{
types.GetProperty("Create_by").SetValue(source, context.GetName(), null);
@@ -54,10 +45,6 @@ namespace ZR.Admin.WebApi.Extensions
{
types.GetProperty("Update_time").SetValue(source, DateTime.Now, null);
}
//if (types.GetProperty("UpdateID") != null)
//{
// types.GetProperty("UpdateID").SetValue(source, userSession.UserID, null);
//}
if (types.GetProperty("UpdateBy") != null)
{

View File

@@ -1,9 +1,6 @@
using Infrastructure;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Http;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
@@ -130,26 +127,6 @@ namespace ZR.Admin.WebApi.Extensions
return context != null ? context.Request.Path.Value : "";
}
private static void WhiteCookie(HttpContext context, List<Claim> claims)
{
//2.创建声明主题 指定认证方式 这里使用cookie
var claimsIdentity = new ClaimsIdentity(claims, "Login");
Task.Run(async () =>
{
await context.SignInAsync(
JwtBearerDefaults.AuthenticationScheme,//这里要注意的是HttpContext.SignInAsync(AuthenticationType,…) 所设置的Scheme一定要与前面的配置一样这样对应的登录授权才会生效。
new ClaimsPrincipal(claimsIdentity),
new AuthenticationProperties()
{
IsPersistent = true,
AllowRefresh = true,
ExpiresUtc = DateTimeOffset.Now.AddDays(1),//有效时间
});
}).Wait();
}
/// <summary>
/// 设置请求参数
/// </summary>