完成权限点对点

This commit is contained in:
橙子
2022-01-11 16:40:15 +08:00
parent 5a9b37ffa6
commit f624a24a82
22 changed files with 319 additions and 49 deletions

View File

@@ -1040,9 +1040,14 @@ namespace Yi.Framework.Core
public bool SetEntryInHash<T>(string hashId, string key, T value)
{
return this.TryCatch<bool>(() => this.client.SetEntryInHash(hashId, key, TextExtensions.SerializeToString<T>(value)), hashId);
}
public bool SetEntryInHash<T>(string hashId, string key, T value, TimeSpan expiresIn)
{
return this.TryCatch<bool>(() => this.client.SetEntryInHash(hashId, key, TextExtensions.SerializeToString<T>(value)), hashId);
}
public T GetValueFromHash<T>(string hashId, string key)
{
return this.TryCatch<T>(() => JsonSerializer.DeserializeFromString<T>(this.client.GetValueFromHash(hashId, key)), hashId);

View File

@@ -37,10 +37,11 @@ namespace Yi.Framework.Core
claims.Add(new Claim(JwtRegisteredClaimNames.Exp, $"{new DateTimeOffset(DateTime.Now.AddMinutes(30)).ToUnixTimeSeconds()}"));
claims.Add(new Claim(ClaimTypes.Name, _user.user.username));
claims.Add(new Claim(ClaimTypes.Sid, _user.user.id.ToString()));
foreach (var k in _user?.menuIds)
{
claims.Add(new Claim("menuIds",k.id.ToString()));
}
//现在不存放在jwt中而存放在redis中
//foreach (var k in _user?.menuIds)
//{
// claims.Add(new Claim("menuIds",k.id.ToString()));
//}
foreach (var k in _user.user.roles)
{
claims.Add(new Claim(ClaimTypes.Role, k.role_name));