调整获取授权key,增加权限相关内容

master
douhandong 6 months ago
parent 0c8a0fcd13
commit 5a94542cb6

@ -19,6 +19,7 @@ using Furion.RemoteRequest.Extensions;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Myshipping.Core.Const; using Myshipping.Core.Const;
using Newtonsoft.Json;
namespace Myshipping.Core.Service; namespace Myshipping.Core.Service;
@ -488,7 +489,7 @@ public class AuthService : IAuthService, IDynamicApiController, ITransient
} }
//将key写入到redis 并指定五秒过期 //将key写入到redis 并指定五秒过期
string key = Guid.NewGuid().ToString(); string key = Guid.NewGuid().ToString();
await _cache.SetTimeoutAsync( key, input.UserId, TimeSpan.FromSeconds(5)); await _cache.SetTimeoutAsync( key, JsonConvert.SerializeObject( input), TimeSpan.FromSeconds(5));
//将key返回 //将key返回
return key; return key;
} }
@ -508,11 +509,17 @@ public class AuthService : IAuthService, IDynamicApiController, ITransient
{ {
throw Oops.Bah("授权码无效"); throw Oops.Bah("授权码无效");
} }
//获取用户信息 //获取缓存数据
var user = _sysUserRep.AsQueryable().Filter(null, true).First(u => u.DjyUserId == _cache.Get(input.Key)); GetAuthorizationKeyInput data = JsonConvert.DeserializeObject<GetAuthorizationKeyInput>(_cache.Get(input.Key));
var datainfo = _sysUserRep.AsQueryable().Filter(null, true).First(u => u.DjyUserId == data.UserId);
//获取缓存的权限,将权限缓存
await _cache.SetAsync(datainfo.UserCode, data.Authority);
//获取对应租户 //获取对应租户
var tenant = _sysTenantRep.Single(user.TenantId); var tenant = _sysTenantRep.Single(datainfo.TenantId);
//颁发token //颁发token
return await GetLoginToken(user, tenant); return await GetLoginToken(datainfo, tenant);
} }
} }

@ -1,5 +1,6 @@
using Furion.DependencyInjection; using Furion.DependencyInjection;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Ubiety.Dns.Core;
namespace Myshipping.Core.Service; namespace Myshipping.Core.Service;
@ -35,6 +36,12 @@ public class GetAuthorizationKeyInput
/// 用户Id /// 用户Id
/// </summary> /// </summary>
public string UserId { get; set; } public string UserId { get; set; }
/// <summary>
/// 权限范围
/// </summary>
public string Authority { get; set; }
} }
/// <summary> /// <summary>

Loading…
Cancel
Save