From 10a608c0af8902b413b76c6f5b5e103d8cea079f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B7=B3?= <454313500@qq.com> Date: Mon, 11 Dec 2023 10:51:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E8=BF=87=E6=9C=9Ftoken=E7=9A=84=E5=8F=91=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sqlsugar/SqlSugarDbContext.cs | 4 ++-- .../Rbac/Services/Impl/AccountService.cs | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Yi.Furion.Net6/Yi.Framework.Infrastructure/Sqlsugar/SqlSugarDbContext.cs b/Yi.Furion.Net6/Yi.Framework.Infrastructure/Sqlsugar/SqlSugarDbContext.cs index a8e3216c..28e6dd9d 100644 --- a/Yi.Furion.Net6/Yi.Framework.Infrastructure/Sqlsugar/SqlSugarDbContext.cs +++ b/Yi.Furion.Net6/Yi.Framework.Infrastructure/Sqlsugar/SqlSugarDbContext.cs @@ -112,7 +112,7 @@ namespace Yi.Framework.Infrastructure.Sqlsugar if (entityInfo.PropertyName.Equals(nameof(IAuditedObject.LastModificationTime))) { //不等于默认最小值,其他null或者有值都进行赋值 - if (!DateTime.MinValue.Equals((DateTime)oldValue)) + if (!DateTime.MinValue.Equals(oldValue)) { entityInfo.SetValue(DateTime.Now); } @@ -138,7 +138,7 @@ namespace Yi.Framework.Infrastructure.Sqlsugar if (entityInfo.PropertyName.Equals(nameof(IAuditedObject.CreationTime))) { //为空或者为默认最小值都进行赋值 - if (oldValue is null || DateTime.MinValue.Equals((DateTime)oldValue)) + if (oldValue is null || DateTime.MinValue.Equals(oldValue)) { entityInfo.SetValue(DateTime.Now); } diff --git a/Yi.Furion.Net6/Yi.Furion.Application/Rbac/Services/Impl/AccountService.cs b/Yi.Furion.Net6/Yi.Furion.Application/Rbac/Services/Impl/AccountService.cs index 9951bfaf..53aa00e6 100644 --- a/Yi.Furion.Net6/Yi.Furion.Application/Rbac/Services/Impl/AccountService.cs +++ b/Yi.Furion.Net6/Yi.Furion.Application/Rbac/Services/Impl/AccountService.cs @@ -1,4 +1,5 @@ using System.Text.RegularExpressions; +using Furion.Authorization; using Furion.EventBus; using IPTools.Core; using Microsoft.AspNetCore.Http; @@ -27,10 +28,10 @@ namespace Yi.Furion.Application.Rbac.Services.Impl public class AccountService : ApplicationService, IAccountService, ITransient, IDynamicApiController { - public AccountService(IUserRepository userRepository, ICurrentUser currentUser, AccountManager accountManager, IRepository menuRepository, SmsAliyunManager smsAliyunManager, IOptions smsAliyunManagerOptions, SecurityCodeHelper securityCode, IMemoryCache memoryCache, IEventPublisher eventPublisher, IHttpContextAccessor httpContextAccessor) => - (_userRepository, _currentUser, _accountManager, _menuRepository, _smsAliyunManager, _smsAliyunManagerOptions, _securityCode, _memoryCache, _eventPublisher, _httpContextAccessor) = - (userRepository, currentUser, accountManager, menuRepository, smsAliyunManager, smsAliyunManagerOptions, securityCode, memoryCache, eventPublisher, httpContextAccessor); - + public AccountService(IUserRepository userRepository, ICurrentUser currentUser, AccountManager accountManager, IRepository menuRepository, SmsAliyunManager smsAliyunManager, IOptions smsAliyunManagerOptions, SecurityCodeHelper securityCode, IMemoryCache memoryCache, IEventPublisher eventPublisher, IHttpContextAccessor httpContextAccessor,IOptions jwtOptions) => + (_userRepository, _currentUser, _accountManager, _menuRepository, _smsAliyunManager, _smsAliyunManagerOptions, _securityCode, _memoryCache, _eventPublisher, _httpContextAccessor, _jwtOptions) = + (userRepository, currentUser, accountManager, menuRepository, smsAliyunManager, smsAliyunManagerOptions, securityCode, memoryCache, eventPublisher, httpContextAccessor, jwtOptions); + private IOptions _jwtOptions; private IUserRepository _userRepository { get; set; } @@ -144,7 +145,7 @@ namespace Yi.Furion.Application.Rbac.Services.Impl //创建token - var accessToken = JWTEncryption.Encrypt(_accountManager.UserInfoToClaim(userInfo)); + var accessToken = JWTEncryption.Encrypt(_accountManager.UserInfoToClaim(userInfo), _jwtOptions.Value.ExpiredTime); return new { Token = accessToken }; }