Compare commits

..

No commits in common. "f0f6f0bd238ee93dc686e057769b2bee07459440" and "d3e7b3a8d89abda095a6b0bb0838a3be66d20372" have entirely different histories.

4 changed files with 21 additions and 55 deletions

View File

@ -32,7 +32,6 @@ 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
{
@ -109,7 +108,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;
@ -227,7 +226,23 @@ namespace IRaCIS.Api.Controllers
var email = returnModel.Data.BasicInfo.EMail;
var hiddenEmail = EmailMaskHelper.MaskEmail(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
returnModel.Data.BasicInfo.EMail = hiddenEmail;

View File

@ -1,44 +0,0 @@
using NPOI.SS.Formula.Functions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IRaCIS.Core.Application.Helper
{
public static class EmailMaskHelper
{
//显示位数3分之2的位数向上取整
//取哪几个个值:最后一位和前面几位
//其他3个***。
//比如hlj23@126.com
//为hlj***3@126.com
//he@126.com
//为h*** e@126.com
public static string MaskEmail(string email)
{
// 找到 "@" 符号的位置
int atIndex = email.IndexOf('@');
string visiblePartBefore = email.Substring(0, atIndex);
string afterAt = email.Substring(atIndex + 1);
int visibleLength = (int)Math.Ceiling((double)visiblePartBefore.Length * 2 / 3);
// 替换中间两位字符为星号
string hiddenPartBeforeAt = visiblePartBefore.Substring(0, visibleLength - 1) + "***" + visiblePartBefore.Last();
// 组合隐藏和可见部分
string hiddenEmail = hiddenPartBeforeAt + "@" + afterAt;
return hiddenEmail;
}
}
}

View File

@ -18,7 +18,6 @@ using LoginReturnDTO = IRaCIS.Application.Contracts.LoginReturnDTO;
using IRaCIS.Core.Application.Auth;
using BeetleX.Redis.Commands;
using IRaCIS.Core.Domain.Models;
using IRaCIS.Core.Application.Helper;
namespace IRaCIS.Application.Services
{
@ -677,8 +676,7 @@ namespace IRaCIS.Application.Services
await _mailVerificationService.SenMFAVerifyEmail(userId, userInfo.FullName, userInfo.EMail, verificationCode, (UserMFAType)mfaType);
var hiddenEmail = EmailMaskHelper.MaskEmail(userInfo.EMail);
return ResponseOutput.Ok(hiddenEmail);
return ResponseOutput.Ok();
}
/// <summary>

View File

@ -261,12 +261,9 @@ namespace IRaCIS.Application.Services
[AllowAnonymous]
public async Task<string> testEmail([FromServices] IWebHostEnvironment env ,string email)
public async Task testwwwww([FromServices] IWebHostEnvironment env)
{
var hiddenEmail = EmailMaskHelper.MaskEmail(email);
return hiddenEmail;
await Task.CompletedTask;
}