删除无用代码
This commit is contained in:
parent
67c6402dc9
commit
58e6f5872f
@ -30,11 +30,6 @@ namespace ZR.Admin.WebApi.Controllers.monitor
|
|||||||
[HttpGet("monitor/cache")]
|
[HttpGet("monitor/cache")]
|
||||||
public ApiResult GetCache()
|
public ApiResult GetCache()
|
||||||
{
|
{
|
||||||
string redis_connString = Options.Redis;
|
|
||||||
var rs = new CSRedis.CSRedisClient(redis_connString);
|
|
||||||
|
|
||||||
RedisHelper.Initialization(rs);//初始化Redis
|
|
||||||
|
|
||||||
return ToJson(1);
|
return ToJson(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -43,9 +43,6 @@ namespace ZR.Admin.WebApi.Framework
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static string GenerateJwtToken(List<Claim> claims, JwtSettings jwtSettings)
|
public static string GenerateJwtToken(List<Claim> claims, JwtSettings jwtSettings)
|
||||||
{
|
{
|
||||||
//JwtSettings jwtSettings = new();
|
|
||||||
//ConfigUtils.Instance.Bind("JwtSettings", jwtSettings);
|
|
||||||
|
|
||||||
var authTime = DateTime.Now;
|
var authTime = DateTime.Now;
|
||||||
var expiresAt = authTime.AddMinutes(jwtSettings.Expire);
|
var expiresAt = authTime.AddMinutes(jwtSettings.Expire);
|
||||||
var tokenHandler = new JwtSecurityTokenHandler();
|
var tokenHandler = new JwtSecurityTokenHandler();
|
||||||
@ -74,14 +71,14 @@ namespace ZR.Admin.WebApi.Framework
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static TokenValidationParameters ValidParameters()
|
public static TokenValidationParameters ValidParameters()
|
||||||
{
|
{
|
||||||
JwtSettings jwtSettings = new();
|
JwtSettings jwtSettings = new JwtSettings();
|
||||||
ConfigUtils.Instance.Bind("JwtSettings", jwtSettings);
|
ConfigUtils.Instance.Bind("JwtSettings", jwtSettings);
|
||||||
if (jwtSettings == null || jwtSettings.SecretKey.IsEmpty())
|
if (jwtSettings == null || jwtSettings.SecretKey.IsEmpty())
|
||||||
{
|
{
|
||||||
return null;
|
throw new Exception("JwtSettings获取失败");
|
||||||
}
|
}
|
||||||
var key = Encoding.ASCII.GetBytes(jwtSettings.SecretKey);
|
var key = Encoding.ASCII.GetBytes(jwtSettings.SecretKey);
|
||||||
|
|
||||||
var tokenDescriptor = new TokenValidationParameters
|
var tokenDescriptor = new TokenValidationParameters
|
||||||
{
|
{
|
||||||
ValidateIssuerSigningKey = true,
|
ValidateIssuerSigningKey = true,
|
||||||
@ -130,8 +127,6 @@ namespace ZR.Admin.WebApi.Framework
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//var userId = jwtToken.FirstOrDefault(x => x.Type == "primarysid").Value;
|
|
||||||
//var userName = jwtToken.FirstOrDefault(x => x.Type == "unique_name").Value;
|
|
||||||
var userData = jwtToken.FirstOrDefault(x => x.Type == ClaimTypes.UserData).Value;
|
var userData = jwtToken.FirstOrDefault(x => x.Type == ClaimTypes.UserData).Value;
|
||||||
|
|
||||||
LoginUser loginUser = JsonConvert.DeserializeObject<LoginUser>(userData);
|
LoginUser loginUser = JsonConvert.DeserializeObject<LoginUser>(userData);
|
||||||
|
|||||||
@ -50,12 +50,8 @@ namespace ZR.Admin.WebApi
|
|||||||
services.AddSession();
|
services.AddSession();
|
||||||
services.AddHttpContextAccessor();
|
services.AddHttpContextAccessor();
|
||||||
|
|
||||||
|
|
||||||
//绑定整个对象到Model上
|
//绑定整个对象到Model上
|
||||||
services.Configure<OptionsSetting>(Configuration);
|
services.Configure<OptionsSetting>(Configuration);
|
||||||
services.Configure<JwtSettings>(Configuration);
|
|
||||||
var jwtSettings = new JwtSettings();
|
|
||||||
Configuration.Bind("JwtSettings", jwtSettings);
|
|
||||||
|
|
||||||
//Cookie 认证
|
//Cookie 认证
|
||||||
services.AddAuthentication(options =>
|
services.AddAuthentication(options =>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user