修改隐藏邮箱的算法

This commit is contained in:
2024-07-31 10:01:48 +08:00
parent a2ca3a8245
commit 52b60338c3
4 changed files with 55 additions and 21 deletions
+3 -18
View File
@@ -32,6 +32,7 @@ using IRaCIS.Core.Application.Contracts;
using LoginReturnDTO = IRaCIS.Application.Contracts.LoginReturnDTO;
using DocumentFormat.OpenXml.Spreadsheet;
using AutoMapper.QueryableExtensions;
using NetTopologySuite.Algorithm;
namespace IRaCIS.Api.Controllers
{
@@ -108,7 +109,7 @@ namespace IRaCIS.Api.Controllers
{
//MFA 邮箱验证 前端传递用户Id 和MFACode
if (loginUser.UserId != null && _verifyConfig.CurrentValue.OpenLoginMFA)
if (loginUser.UserId != null && _verifyConfig.CurrentValue.OpenLoginMFA)
{
Guid userId = (Guid)loginUser.UserId;
@@ -226,23 +227,7 @@ namespace IRaCIS.Api.Controllers
var email = returnModel.Data.BasicInfo.EMail;
#region Email
// 找到 "@" 符号的位置
int atIndex = email.IndexOf('@');
// 替换 "@" 符号前的中间两位为星号
string visiblePart = email.Substring(0, atIndex);
int startIndex = (visiblePart.Length - 2) / 2;
// 替换中间两位字符为星号
string hiddenPartBeforeAt = visiblePart.Substring(0, startIndex) + "**" + visiblePart.Substring(startIndex + 2);
string afterAt = email.Substring(atIndex + 1);
// 组合隐藏和可见部分
string hiddenEmail = hiddenPartBeforeAt + "@" + afterAt;
#endregion
var hiddenEmail = EmailMaskHelper.MaskEmail(email);
returnModel.Data.BasicInfo.EMail = hiddenEmail;