fix: 修复发授令牌问题
This commit is contained in:
@@ -19,7 +19,7 @@ namespace Yi.Framework.Rbac.Application.EventHandlers
|
||||
private readonly ILogger<LoginEventHandler> _logger;
|
||||
private readonly IRepository<LoginLogEntity> _loginLogRepository;
|
||||
public LoginEventHandler(ILogger<LoginEventHandler> logger, IRepository<LoginLogEntity> loginLogRepository) { _logger = logger; _loginLogRepository = loginLogRepository; }
|
||||
public Task HandleEventAsync(LoginEventArgs eventData)
|
||||
public async Task HandleEventAsync(LoginEventArgs eventData)
|
||||
{
|
||||
_logger.LogInformation($"用户【{eventData.UserId}:{eventData.UserName}】登入系统");
|
||||
var loginLogEntity = eventData.Adapt<LoginLogEntity>();
|
||||
@@ -27,8 +27,7 @@ namespace Yi.Framework.Rbac.Application.EventHandlers
|
||||
loginLogEntity.LoginUser = eventData.UserName;
|
||||
loginLogEntity.CreatorId = eventData.UserId;
|
||||
//异步插入
|
||||
_loginLogRepository.InsertAsync(loginLogEntity);
|
||||
return Task.CompletedTask;
|
||||
await _loginLogRepository.InsertAsync(loginLogEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
using Quartz;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Volo.Abp.BackgroundWorkers.Quartz;
|
||||
|
||||
namespace Yi.Framework.Rbac.Application.Jobs
|
||||
{
|
||||
//public class TestJob : QuartzBackgroundWorkerBase
|
||||
//public class BackupDataBaseJob : QuartzBackgroundWorkerBase
|
||||
//{
|
||||
// public TestJob()
|
||||
// {
|
||||
@@ -151,13 +151,13 @@ namespace Yi.Framework.Rbac.Application.Services
|
||||
/// <summary>
|
||||
/// 创建令牌
|
||||
/// </summary>
|
||||
/// <param name="dic"></param>
|
||||
/// <param name="kvs"></param>
|
||||
/// <returns></returns>
|
||||
private string CreateToken(Dictionary<string, object> dic)
|
||||
private string CreateToken(List<KeyValuePair<string, string>> kvs)
|
||||
{
|
||||
var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_jwtOptions.SecurityKey));
|
||||
var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
|
||||
var claims = dic.Select(x => new Claim(x.Key, x.Value.ToString())).ToList();
|
||||
var claims = kvs.Select(x => new Claim(x.Key, x.Value.ToString())).ToList();
|
||||
var token = new JwtSecurityToken(
|
||||
issuer: _jwtOptions.Issuer,
|
||||
audience: _jwtOptions.Audience,
|
||||
|
||||
Reference in New Issue
Block a user