修改账号token

Uat_IRC_Net8
hang 2024-12-20 14:54:11 +08:00
parent d165632cc8
commit 519eeb6df1
20 changed files with 167 additions and 166 deletions

View File

@ -1,5 +1,6 @@
using Amazon.Auth.AccessControlPolicy; using Amazon.Auth.AccessControlPolicy;
using Amazon.SecurityToken; using Amazon.SecurityToken;
using AutoMapper;
using Azure.Core; using Azure.Core;
using IdentityModel.Client; using IdentityModel.Client;
using IdentityModel.OidcClient; using IdentityModel.OidcClient;
@ -115,7 +116,7 @@ namespace IRaCIS.Api.Controllers
[FromServices] IReadingImageTaskService readingImageTaskService, [FromServices] IReadingImageTaskService readingImageTaskService,
[FromServices] IOptionsMonitor<ServiceVerifyConfigOption> _verifyConfig, [FromServices] IOptionsMonitor<ServiceVerifyConfigOption> _verifyConfig,
[FromServices] IOptionsMonitor<SystemEmailSendConfig> _emailConfig, [FromServices] IOptionsMonitor<SystemEmailSendConfig> _emailConfig,
[FromServices]IMapper _mapper,
[FromServices] IMailVerificationService _mailVerificationService) [FromServices] IMailVerificationService _mailVerificationService)
{ {
var emailConfig = _emailConfig.CurrentValue; var emailConfig = _emailConfig.CurrentValue;
@ -135,7 +136,7 @@ namespace IRaCIS.Api.Controllers
var loginReturn = new LoginReturnDTO() { BasicInfo = basicInfo }; var loginReturn = new LoginReturnDTO() { BasicInfo = basicInfo };
loginReturn.JWTStr = _tokenService.GetToken(IRaCISClaims.Create(loginReturn.BasicInfo)); loginReturn.JWTStr = _tokenService.GetToken(new UserTokenInfo() { UserRoleId = basicInfo.Id });
// 创建一个 CookieOptions 对象,用于设置 Cookie 的属性 // 创建一个 CookieOptions 对象,用于设置 Cookie 的属性
@ -248,7 +249,7 @@ namespace IRaCIS.Api.Controllers
//修改密码 //修改密码
if (returnModel.Data.BasicInfo.IsFirstAdd || returnModel.Data.BasicInfo.LoginState == 1) if (returnModel.Data.BasicInfo.IsFirstAdd || returnModel.Data.BasicInfo.LoginState == 1)
{ {
returnModel.Data.JWTStr = _tokenService.GetToken(IRaCISClaims.Create(returnModel.Data.BasicInfo)); returnModel.Data.JWTStr = _tokenService.GetToken(_mapper.Map<UserTokenInfo>(returnModel.Data.BasicInfo));
} }
else else
{ {
@ -260,7 +261,7 @@ namespace IRaCIS.Api.Controllers
} }
else else
{ {
returnModel.Data.JWTStr = _tokenService.GetToken(IRaCISClaims.Create(returnModel.Data.BasicInfo)); returnModel.Data.JWTStr = _tokenService.GetToken(_mapper.Map<UserTokenInfo>(returnModel.Data.BasicInfo));
// 创建一个 CookieOptions 对象,用于设置 Cookie 的属性 // 创建一个 CookieOptions 对象,用于设置 Cookie 的属性
var option = new CookieOptions var option = new CookieOptions
@ -309,18 +310,13 @@ namespace IRaCIS.Api.Controllers
[AllowAnonymous] [AllowAnonymous]
public IResponseOutput ShareImage([FromServices] ITokenService _tokenService) public IResponseOutput ShareImage([FromServices] ITokenService _tokenService)
{ {
var token = _tokenService.GetToken(IRaCISClaims.Create(new UserBasicInfo() var token = _tokenService.GetToken(new UserTokenInfo()
{ {
Id = Guid.NewGuid(), UserRoleId = Guid.NewGuid(),
IsReviewer = false,
IsAdmin = false,
RealName = "Share001",
UserName = "Share001", UserName = "Share001",
Sex = 0,
//UserType = "ShareType",
UserTypeEnum = UserTypeEnum.ShareImage, UserTypeEnum = UserTypeEnum.ShareImage,
Code = "ShareCode001",
})); });
return ResponseOutput.Ok("/showdicom?studyId=f7b67793-8155-0223-2f15-118f2642efb8&type=Share&token=" + token); return ResponseOutput.Ok("/showdicom?studyId=f7b67793-8155-0223-2f15-118f2642efb8&type=Share&token=" + token);
} }

View File

@ -34,7 +34,7 @@
<param name="doctorId"></param> <param name="doctorId"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:IRaCIS.Api.Controllers.ExtraController.Login(IRaCIS.Application.Contracts.UserLoginDTO,ZiggyCreatures.Caching.Fusion.IFusionCache,IRaCIS.Core.Application.Service.IUserService,IRaCIS.Core.Application.Auth.ITokenService,IRaCIS.Core.Application.Contracts.IReadingImageTaskService,Microsoft.Extensions.Options.IOptionsMonitor{IRaCIS.Core.Domain.Share.ServiceVerifyConfigOption},Microsoft.Extensions.Options.IOptionsMonitor{IRaCIS.Core.Domain.Share.SystemEmailSendConfig},IRaCIS.Core.Application.Service.IMailVerificationService)"> <member name="M:IRaCIS.Api.Controllers.ExtraController.Login(IRaCIS.Application.Contracts.UserLoginDTO,ZiggyCreatures.Caching.Fusion.IFusionCache,IRaCIS.Core.Application.Service.IUserService,IRaCIS.Core.Application.Auth.ITokenService,IRaCIS.Core.Application.Contracts.IReadingImageTaskService,Microsoft.Extensions.Options.IOptionsMonitor{IRaCIS.Core.Domain.Share.ServiceVerifyConfigOption},Microsoft.Extensions.Options.IOptionsMonitor{IRaCIS.Core.Domain.Share.SystemEmailSendConfig},AutoMapper.IMapper,IRaCIS.Core.Application.Service.IMailVerificationService)">
<summary> 系统用户登录接口[New] </summary> <summary> 系统用户登录接口[New] </summary>
</member> </member>
<member name="M:IRaCIS.Api.Controllers.ExtraController.OAuthCallBack(System.String,System.String)"> <member name="M:IRaCIS.Api.Controllers.ExtraController.OAuthCallBack(System.String,System.String)">

View File

@ -17,7 +17,7 @@ namespace IRaCIS.Core.API
{ {
public virtual string GetUserId(HubConnectionContext connection) public virtual string GetUserId(HubConnectionContext connection)
{ {
return connection.User?.FindFirst(JwtIRaCISClaimType.Id)?.Value!; return connection.User?.FindFirst(JwtIRaCISClaimType.IdentityUserId)?.Value!;
} }
} }

View File

@ -38,7 +38,7 @@ namespace IRaCIS.Core.API
diagnosticContext.Set("QueryString", request.QueryString.Value); diagnosticContext.Set("QueryString", request.QueryString.Value);
} }
diagnosticContext.Set("FullName", httpContext?.User?.FindFirst(JwtIRaCISClaimType.RealName)?.Value); diagnosticContext.Set("FullName", httpContext?.User?.FindFirst(JwtIRaCISClaimType.FullName)?.Value);
diagnosticContext.Set("UserType", httpContext?.User?.FindFirst(JwtIRaCISClaimType.UserTypeShortName)?.Value); diagnosticContext.Set("UserType", httpContext?.User?.FindFirst(JwtIRaCISClaimType.UserTypeShortName)?.Value);

View File

@ -1,46 +0,0 @@
using IRaCIS.Application.Contracts;
using IRaCIS.Core.Domain.Share;
namespace IRaCIS.Core.Application.Auth
{
public class IRaCISClaims
{
public Guid Id { get; set; }
public string FullName { get; set; } = String.Empty;
public string Code { get; set; } = String.Empty;
public string RealName { get; set; } = String.Empty;
public string UserTypeShortName { get; set; } = String.Empty;
public UserTypeEnum UserTypeEnum { get; set; }
public string PermissionStr { get; set; } = String.Empty;
public Guid UserTypeId { get; set; }
public int IsAdmin { get; }
public bool IsTestUser { get; set; }
public bool IsZhiZhun { get; set; }
public string Phone { get; set; } = String.Empty;
public static IRaCISClaims Create(UserBasicInfo user)
{
return new IRaCISClaims
{
Id = user.Id,
FullName = user.UserName,
RealName = user.RealName,
UserTypeEnum = user.UserTypeEnum,
UserTypeId = user.UserTypeId,
IsTestUser = user.IsTestUser,
Code = user.Code,
PermissionStr = user.PermissionStr,
IsZhiZhun = user.IsZhiZhun,
UserTypeShortName = user.UserTypeShortName
};
}
}
}

View File

@ -8,7 +8,7 @@ namespace IRaCIS.Core.Application.Auth
public interface ITokenService public interface ITokenService
{ {
string GetToken(IRaCISClaims user); string GetToken(UserTokenInfo user);
} }
@ -21,16 +21,16 @@ namespace IRaCIS.Core.Application.Auth
_jwtSetting = option.Value; _jwtSetting = option.Value;
} }
public string GetToken(IRaCISClaims user) public string GetToken(UserTokenInfo user)
{ {
//创建用户身份标识,可按需要添加更多信息 //创建用户身份标识,可按需要添加更多信息
var claims = new Claim[] var claims = new Claim[]
{ {
new Claim(Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()), new Claim(Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()),
new Claim(JwtIRaCISClaimType.Id, user.Id.ToString()), new Claim(JwtIRaCISClaimType.IdentityUserId, user.IdentityUserId.ToString()),
new Claim(JwtIRaCISClaimType.Name, user.FullName), new Claim(JwtIRaCISClaimType.UserRoleId, user.UserRoleId.ToString()),
new Claim(JwtIRaCISClaimType.RealName, user.RealName), new Claim(JwtIRaCISClaimType.UserName, user.UserName),
new Claim(JwtIRaCISClaimType.Code,user.Code), new Claim(JwtIRaCISClaimType.FullName, user.FullName),
new Claim(JwtIRaCISClaimType.UserTypeId,user.UserTypeId.ToString()), new Claim(JwtIRaCISClaimType.UserTypeId,user.UserTypeId.ToString()),
new Claim(JwtIRaCISClaimType.UserTypeEnum,user.UserTypeEnum.ToString()), new Claim(JwtIRaCISClaimType.UserTypeEnum,user.UserTypeEnum.ToString()),
new Claim(JwtIRaCISClaimType.UserTypeEnumInt,((int)user.UserTypeEnum).ToString()), new Claim(JwtIRaCISClaimType.UserTypeEnumInt,((int)user.UserTypeEnum).ToString()),

View File

@ -0,0 +1,27 @@
using IRaCIS.Application.Contracts;
using IRaCIS.Core.Domain.Share;
namespace IRaCIS.Core.Application.Auth
{
public class UserTokenInfo
{
public Guid IdentityUserId { get; set; }
public Guid UserRoleId { get; set; }
public Guid UserTypeId { get; set; }
public UserTypeEnum UserTypeEnum { get; set; }
public string UserName { get; set; } = string.Empty;
public string FullName { get; set; } = string.Empty;
public string PermissionStr { get; set; } = string.Empty;
public bool IsTestUser { get; set; }
public bool IsZhiZhun { get; set; }
public string UserTypeShortName { get; set; } = string.Empty;
}
}

View File

@ -48,7 +48,7 @@ public class LimitUserRequestAuthorization(
//2、在这里取缓存 进行比较 看是否有其他人进行了登陆,如果其他人登陆了,就把之前用户挤掉 //2、在这里取缓存 进行比较 看是否有其他人进行了登陆,如果其他人登陆了,就把之前用户挤掉
var cacheUserToken = await _fusionCache.GetOrDefaultAsync<string>(CacheKeys.UserToken(_userInfo.Id)); var cacheUserToken = await _fusionCache.GetOrDefaultAsync<string>(CacheKeys.UserToken(_userInfo.IdentityUserId));
@ -58,17 +58,17 @@ public class LimitUserRequestAuthorization(
cacheUserToken = _userInfo.UserToken; cacheUserToken = _userInfo.UserToken;
//设置当前用户最新Token //设置当前用户最新Token
await _fusionCache.SetAsync(CacheKeys.UserToken(_userInfo.Id), _userInfo.UserToken, TimeSpan.FromDays(7)); await _fusionCache.SetAsync(CacheKeys.UserToken(_userInfo.IdentityUserId), _userInfo.UserToken, TimeSpan.FromDays(7));
//重启应用程序,所有人续期,不一下子踢出所有人 //重启应用程序,所有人续期,不一下子踢出所有人
await _fusionCache.SetAsync(CacheKeys.UserAutoLoginOut(_userInfo.Id), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), TimeSpan.FromMinutes(minutes)); await _fusionCache.SetAsync(CacheKeys.UserAutoLoginOut(_userInfo.IdentityUserId), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), TimeSpan.FromMinutes(minutes));
} }
//是同一个人 //是同一个人
else if (cacheUserToken == _userInfo.UserToken) else if (cacheUserToken == _userInfo.UserToken)
{ {
var cacheTime = await _fusionCache.GetOrDefaultAsync<string>(CacheKeys.UserAutoLoginOut(_userInfo.Id)); var cacheTime = await _fusionCache.GetOrDefaultAsync<string>(CacheKeys.UserAutoLoginOut(_userInfo.IdentityUserId));
//过期了 需要自动退出 //过期了 需要自动退出
if (string.IsNullOrEmpty(cacheTime)) if (string.IsNullOrEmpty(cacheTime))
@ -80,7 +80,7 @@ public class LimitUserRequestAuthorization(
} }
else else
{ {
await _fusionCache.SetAsync(CacheKeys.UserAutoLoginOut(_userInfo.Id), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), TimeSpan.FromMinutes(minutes)); await _fusionCache.SetAsync(CacheKeys.UserAutoLoginOut(_userInfo.IdentityUserId), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), TimeSpan.FromMinutes(minutes));
} }
} }
else else

View File

@ -41,19 +41,19 @@ public class LimitUserRequestAuthorizationEndpointFilter(
} }
// 获取缓存中的用户 token // 获取缓存中的用户 token
var cacheUserToken = await _fusionCache.GetOrDefaultAsync<string>(CacheKeys.UserToken(_userInfo.Id)); var cacheUserToken = await _fusionCache.GetOrDefaultAsync<string>(CacheKeys.UserToken(_userInfo.IdentityUserId));
// 缓存中没有取到 token // 缓存中没有取到 token
if (string.IsNullOrWhiteSpace(cacheUserToken)) if (string.IsNullOrWhiteSpace(cacheUserToken))
{ {
// 设置当前用户最新 token // 设置当前用户最新 token
await _fusionCache.SetAsync(CacheKeys.UserToken(_userInfo.Id), _userInfo.UserToken, TimeSpan.FromDays(7)); await _fusionCache.SetAsync(CacheKeys.UserToken(_userInfo.IdentityUserId), _userInfo.UserToken, TimeSpan.FromDays(7));
await _fusionCache.SetAsync(CacheKeys.UserAutoLoginOut(_userInfo.Id), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), TimeSpan.FromMinutes(minutes)); await _fusionCache.SetAsync(CacheKeys.UserAutoLoginOut(_userInfo.IdentityUserId), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), TimeSpan.FromMinutes(minutes));
} }
// 如果是同一个用户 // 如果是同一个用户
else if (cacheUserToken == _userInfo.UserToken) else if (cacheUserToken == _userInfo.UserToken)
{ {
var cacheTime = await _fusionCache.GetOrDefaultAsync<string>(CacheKeys.UserAutoLoginOut(_userInfo.Id)); var cacheTime = await _fusionCache.GetOrDefaultAsync<string>(CacheKeys.UserAutoLoginOut(_userInfo.IdentityUserId));
// 如果过期,自动登出 // 如果过期,自动登出
if (string.IsNullOrEmpty(cacheTime)) if (string.IsNullOrEmpty(cacheTime))
@ -63,7 +63,7 @@ public class LimitUserRequestAuthorizationEndpointFilter(
} }
else else
{ {
await _fusionCache.SetAsync(CacheKeys.UserAutoLoginOut(_userInfo.Id), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), TimeSpan.FromMinutes(minutes)); await _fusionCache.SetAsync(CacheKeys.UserAutoLoginOut(_userInfo.IdentityUserId), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), TimeSpan.FromMinutes(minutes));
} }
} }
else else

View File

@ -350,7 +350,7 @@ namespace IRaCIS.Core.Application.Service
//---[来自展影IRC] 关于创建账户的提醒 //---[来自展影IRC] 关于创建账户的提醒
var token = _tokenService.GetToken(IRaCISClaims.Create(_mapper.Map<UserBasicInfo>(sysUserInfo))); var token = _tokenService.GetToken(new UserTokenInfo() { UserRoleId = sysUserInfo.Id });
await _userRepository.BatchUpdateNoTrackingAsync(t => t.Id == sysUserInfo.Id, u => new User() { EmailToken = token }); await _userRepository.BatchUpdateNoTrackingAsync(t => t.Id == sysUserInfo.Id, u => new User() { EmailToken = token });
@ -438,7 +438,7 @@ namespace IRaCIS.Core.Application.Service
// $"[来自展影IRC] [{trialInfo.ResearchProgramNo}]邀请信"; // $"[来自展影IRC] [{trialInfo.ResearchProgramNo}]邀请信";
var token = _tokenService.GetToken(IRaCISClaims.Create(_mapper.Map<UserBasicInfo>(sysUserInfo))); var token = _tokenService.GetToken(new UserTokenInfo() { UserRoleId = sysUserInfo.Id });
if (sysUserInfo.IsFirstAdd) if (sysUserInfo.IsFirstAdd)
{ {
@ -499,7 +499,7 @@ namespace IRaCIS.Core.Application.Service
var token = _tokenService.GetToken(IRaCISClaims.Create(_mapper.Map<UserBasicInfo>(sysUserInfo))); var token = _tokenService.GetToken(new UserTokenInfo() { UserRoleId = sysUserInfo.Id });
if (sysUserInfo.IsFirstAdd) if (sysUserInfo.IsFirstAdd)
{ {
await _userRepository.BatchUpdateNoTrackingAsync(t => t.Id == sysUserInfo.Id, u => new User() { EmailToken = token }); await _userRepository.BatchUpdateNoTrackingAsync(t => t.Id == sysUserInfo.Id, u => new User() { EmailToken = token });
@ -607,13 +607,7 @@ namespace IRaCIS.Core.Application.Service
var basicInfo = IRaCISClaims.Create(_mapper.Map<UserBasicInfo>(sysUserInfo)); var token = _tokenService.GetToken(new UserTokenInfo() { UserRoleId = sysUserInfo.Id });
////第一次添加的时候 注意赋值
//basicInfo.PermissionStr = userType.PermissionStr;
//basicInfo.UserTypeShortName = userType.UserTypeShortName;
var token = _tokenService.GetToken(basicInfo);
if (sysUserInfo.IsFirstAdd) if (sysUserInfo.IsFirstAdd)
{ {

View File

@ -102,18 +102,13 @@ namespace IRaCIS.Core.Application.Services
var resource = new ResourceInfo() var resource = new ResourceInfo()
{ {
StudyId = imageShare.StudyId, StudyId = imageShare.StudyId,
Token = _tokenService.GetToken(IRaCISClaims.Create(new UserBasicInfo() Token = _tokenService.GetToken(new UserTokenInfo()
{ {
Id = Guid.Empty, UserRoleId = Guid.NewGuid(),
IsReviewer = false, FullName = "Share001",
IsAdmin = false,
RealName = "Share001",
UserName = "Share001", UserName = "Share001",
Sex = 0,
//UserType = "ShareType",
UserTypeEnum = UserTypeEnum.ShareImage, UserTypeEnum = UserTypeEnum.ShareImage,
Code = "ShareCode001", })
}))
}; };

View File

@ -21,7 +21,34 @@ namespace IRaCIS.Application.Contracts
public Guid? UserId { get; set; } public Guid? UserId { get; set; }
} }
public class IRCLoginDto
{
public string UserName { get; set; }
public string Password { get; set; }
}
public class LoginSelectRoleReturn
{
public string JwtStr { get; set; }
public bool IsExistMutiAccount => AccountList.Count > 1;
public List<UserAccountInfo> AccountList { get; set; } = new List<UserAccountInfo>();
}
public class UserAccountInfo
{
public Guid Id { get; set; }
public string UserName { get; set; } = string.Empty;
public string FullName { get; set; } = string.Empty;
public string Phone { get; set; } = string.Empty;
public string EMail { get; set; } = string.Empty;
public Guid UserTypeId { get; set; }
public UserTypeEnum UserType { get; set; }
}
public class LoginReturnDTO public class LoginReturnDTO
{ {
public UserBasicInfo BasicInfo { get; set; } = new UserBasicInfo(); public UserBasicInfo BasicInfo { get; set; } = new UserBasicInfo();

View File

@ -142,7 +142,7 @@ namespace IRaCIS.Core.Application.Service
//验证码 6位 //验证码 6位
int verificationCode = new Random().Next(100000, 1000000); int verificationCode = new Random().Next(100000, 1000000);
await _mailVerificationService.SendMailEditEmail(_userInfo.Id, _userInfo.RealName, email, verificationCode); await _mailVerificationService.SendMailEditEmail(_userInfo.Id, _userInfo.FullName, email, verificationCode);
return ResponseOutput.Ok(); return ResponseOutput.Ok();

View File

@ -1,6 +1,7 @@
using AutoMapper; using AutoMapper;
using AutoMapper.EquivalencyExpression; using AutoMapper.EquivalencyExpression;
using IRaCIS.Application.Contracts; using IRaCIS.Application.Contracts;
using IRaCIS.Core.Application.Auth;
using IRaCIS.Core.Application.Contracts; using IRaCIS.Core.Application.Contracts;
using IRaCIS.Core.Application.Service.Reading.Dto; using IRaCIS.Core.Application.Service.Reading.Dto;
using IRaCIS.Core.Application.ViewModel; using IRaCIS.Core.Application.ViewModel;
@ -136,6 +137,10 @@ namespace IRaCIS.Core.Application.Service
; ;
CreateMap<UserFeedBackAddOrEdit, UserFeedBack>().ReverseMap(); CreateMap<UserFeedBackAddOrEdit, UserFeedBack>().ReverseMap();
CreateMap<UserBasicInfo, UserTokenInfo>()
.ForMember(d => d.UserRoleId, c => c.MapFrom(t => t.Id));
} }
} }

View File

@ -1938,7 +1938,7 @@ namespace IRaCIS.Core.Application.Image.QA
qcChallenge.ReUploadUserId = _userInfo.Id; qcChallenge.ReUploadUserId = _userInfo.Id;
qcChallenge.ReUploader = _userInfo.RealName; qcChallenge.ReUploader = _userInfo.FullName;
qcChallenge.LatestMsgTime = DateTime.Now; qcChallenge.LatestMsgTime = DateTime.Now;

View File

@ -236,7 +236,7 @@ namespace IRaCIS.Core.Application.Contracts
result.ReviewStatus = info.ReviewStatus; result.ReviewStatus = info.ReviewStatus;
} }
result.Token = _tokenService.GetToken(IRaCISClaims.Create(new UserBasicInfo() { Id = Guid.NewGuid() })); result.Token = _tokenService.GetToken(new UserTokenInfo() { UserRoleId = Guid.NewGuid() });
} }
} }
@ -441,18 +441,12 @@ namespace IRaCIS.Core.Application.Contracts
return ResponseOutput.Ok(new return ResponseOutput.Ok(new
{ {
TrialSiteSurveyId = currentEntity!.Id, TrialSiteSurveyId = currentEntity!.Id,
Token = _tokenService.GetToken(IRaCISClaims.Create(new UserBasicInfo() Token = _tokenService.GetToken(new UserTokenInfo()
{ {
Id = Guid.NewGuid(), UserRoleId = Guid.NewGuid(),
IsReviewer = false,
IsAdmin = false,
RealName = "SiteSurvey",
UserName = "SiteSurvey", UserName = "SiteSurvey",
Sex = 0,
//UserType = "ShareType",
UserTypeEnum = UserTypeEnum.Undefined, UserTypeEnum = UserTypeEnum.Undefined,
Code = "SiteSurvey", })
}))
}); });
#endregion #endregion

View File

@ -26,22 +26,46 @@ public class User : BaseFullAuditEntity
#endregion #endregion
#region Óû§ÐÅÏ¢
public int Code { get; set; }
public string UserCode { get; set; }
public string UserName { get; set; }
public string EMail { get; set; }
[StringLength(1000)]
public string EmailToken { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Password { get; set; }
public bool PasswordChanged { get; set; }
public string Phone { get; set; }
public int? Sex { get; set; }
public UserStateEnum Status { get; set; } = UserStateEnum.Enable;
public string OrganizationName { get; set; }
public string PositionName { get; set; }
#endregion
[Comment("自动切换下一个任务")] [Comment("自动切换下一个任务")]
public bool AutoCutNextTask { get; set; } public bool AutoCutNextTask { get; set; }
public int Code { get; set; }
public string DepartmentName { get; set; } = null!; public string DepartmentName { get; set; } = null!;
[Comment("医生生成账号后,会有值")] [Comment("医生生成账号后,会有值")]
public Guid? DoctorId { get; set; } public Guid? DoctorId { get; set; }
public string EMail { get; set; } = null!;
[StringLength(1000)]
public string EmailToken { get; set; } = null!;
public string FirstName { get; set; } = null!;
[Comment("首次登录需要修改密码")] [Comment("首次登录需要修改密码")]
public bool IsFirstAdd { get; set; } = true; public bool IsFirstAdd { get; set; } = true;
@ -53,36 +77,19 @@ public class User : BaseFullAuditEntity
[Comment("上一次修改密码的时间")] [Comment("上一次修改密码的时间")]
public DateTime? LastChangePassWordTime { get; set; } public DateTime? LastChangePassWordTime { get; set; }
public string LastLoginIP { get; set; } = null!; public string LastLoginIP { get; set; }
public DateTime? LastLoginTime { get; set; } public DateTime? LastLoginTime { get; set; }
public string LastName { get; set; } = null!;
public string OrganizationName { get; set; } = null!;
public string Password { get; set; } = null!;
public bool PasswordChanged { get; set; }
public string Phone { get; set; } = null!;
public string PositionName { get; set; } = null!;
public int? Sex { get; set; }
public UserStateEnum Status { get; set; } = UserStateEnum.Enable;
public bool SuperAdmin { get; set; } public bool SuperAdmin { get; set; }
public string UserCode { get; set; } = null!;
public string UserName { get; set; } = null!;
public UserTypeEnum UserTypeEnum { get; set; } public UserTypeEnum UserTypeEnum { get; set; }
public Guid UserTypeId { get; set; } public Guid UserTypeId { get; set; }
#region ÐÂÔö×Ö¶Î
//public Guid IdentityUserId { get; set; }
#endregion
} }

View File

@ -8,10 +8,11 @@
Guid Id { get; } Guid Id { get; }
Guid IdentityUserId { get; }
string UserName { get; } string UserName { get; }
string RealName { get; } string FullName { get; }
string ReviewerCode { get; }
bool IsAdmin { get; } bool IsAdmin { get; }

View File

@ -15,13 +15,26 @@ namespace IRaCIS.Core.Domain.Share
} }
/// <summary> /// <summary>
/// 用户Id /// 用户角色Id
/// </summary> /// </summary>
public Guid Id public Guid Id
{ {
get get
{ {
var id = _accessor?.HttpContext?.User?.FindFirst(JwtIRaCISClaimType.Id); var id = _accessor?.HttpContext?.User?.FindFirst(JwtIRaCISClaimType.UserRoleId);
if (id != null && !string.IsNullOrEmpty(id.Value))
{
return Guid.Parse(id.Value);
}
return Guid.Empty;
}
}
public Guid IdentityUserId
{
get
{
var id = _accessor?.HttpContext?.User?.FindFirst(JwtIRaCISClaimType.IdentityUserId);
if (id != null && !string.IsNullOrEmpty(id.Value)) if (id != null && !string.IsNullOrEmpty(id.Value))
{ {
return Guid.Parse(id.Value); return Guid.Parse(id.Value);
@ -51,7 +64,7 @@ namespace IRaCIS.Core.Domain.Share
{ {
get get
{ {
var name = _accessor?.HttpContext?.User?.FindFirst(JwtIRaCISClaimType.Name); var name = _accessor?.HttpContext?.User?.FindFirst(JwtIRaCISClaimType.UserName);
if (name != null && !string.IsNullOrEmpty(name.Value)) if (name != null && !string.IsNullOrEmpty(name.Value))
{ {
@ -63,11 +76,11 @@ namespace IRaCIS.Core.Domain.Share
} }
public string RealName public string FullName
{ {
get get
{ {
var name = _accessor?.HttpContext?.User?.FindFirst(JwtIRaCISClaimType.RealName); var name = _accessor?.HttpContext?.User?.FindFirst(JwtIRaCISClaimType.FullName);
if (name != null && !string.IsNullOrEmpty(name.Value)) if (name != null && !string.IsNullOrEmpty(name.Value))
{ {
@ -78,19 +91,7 @@ namespace IRaCIS.Core.Domain.Share
} }
} }
public string ReviewerCode
{
get
{
var reviewerCode = _accessor?.HttpContext?.User?.FindFirst(JwtIRaCISClaimType.Code);
if (reviewerCode != null && !string.IsNullOrEmpty(reviewerCode.Value))
{
return reviewerCode.Value;
}
return string.Empty;
}
}
public string UserTypeShortName public string UserTypeShortName
@ -342,16 +343,16 @@ namespace IRaCIS.Core.Domain.Share
public struct JwtIRaCISClaimType public struct JwtIRaCISClaimType
{ {
public const string Id = "id"; public const string IdentityUserId = "identityUserId";
public const string UserRoleId = "userRoleId";
public const string Code = "code"; public const string Code = "code";
public const string Name = "name"; public const string UserName = "name";
public const string RealName = "realName"; public const string FullName = "fullName";
public const string UserTypeId = "userTypeId"; public const string UserTypeId = "userTypeId";
public const string UserTypeEnum = "userTypeEnum"; public const string UserTypeEnum = "userTypeEnum";
public const string UserTypeEnumName = "userTypeEnumName"; public const string UserTypeEnumName = "userTypeEnumName";
public const string UserTypeEnumInt = "userTypeEnumInt"; public const string UserTypeEnumInt = "userTypeEnumInt";
public const string UserTypeShortName = "userTypeShortName"; public const string UserTypeShortName = "userTypeShortName";
public const string IsAdmin = "isAdmin";
public const string IsTestUser = "isTestUser"; public const string IsTestUser = "isTestUser";

View File

@ -3531,7 +3531,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
inspection.CreateUserName = _userInfo.UserName; inspection.CreateUserName = _userInfo.UserName;
inspection.CreateUserRealName = _userInfo.RealName; inspection.CreateUserRealName = _userInfo.FullName;
inspection.RoleName = _userInfo.UserTypeShortName; inspection.RoleName = _userInfo.UserTypeShortName;
inspection.CreateUserId = _userInfo.Id; inspection.CreateUserId = _userInfo.Id;
inspection.IP = _userInfo.IP; inspection.IP = _userInfo.IP;