From 0c0f294bf71ce9a87ff465b76b0d67b8afa3a038 Mon Sep 17 00:00:00 2001
From: dyy <807692433@qq.com>
Date: Fri, 12 Jul 2024 14:00:29 +0800
Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E3=80=91=E5=8F=91?=
=?UTF-8?q?=E7=9F=AD=E4=BF=A1=E6=8E=A5=E5=8F=A3=EF=BC=9A=E5=A2=9E=E5=8A=A0?=
=?UTF-8?q?=E6=89=8B=E6=9C=BA=E5=8F=B7=E6=A0=BC=E5=BC=8F=E7=9A=84=E9=AA=8C?=
=?UTF-8?q?=E8=AF=81=EF=BC=9B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Controllers/HomeController.cs | 4 ++++
.../Controllers/LoginController.cs | 4 ++++
.../Learun.Application.WebApi/Modules/UserApi.cs | 4 ++++
.../Modules/UsernologinApi.cs | 4 ++++
.../Learun.Util/Common/CommonHelper.cs | 15 +++++++++++++++
5 files changed, 31 insertions(+)
diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/HomeController.cs b/Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/HomeController.cs
index 3326afb2d..e074d4da2 100644
--- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/HomeController.cs
+++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/HomeController.cs
@@ -760,6 +760,10 @@ namespace Learun.Application.Web.Controllers
{
return Fail("用户手机号不存在!");
}
+ if (!CommonHelper.IsValidMobile(userEntity.F_Mobile))
+ {
+ return Fail("手机号格式不正确!");
+ }
//todo:待取消注释
//string raRndNum = Learun.Util.CommonHelper.RndNum(6);
string raRndNum = "123456";
diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/LoginController.cs b/Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/LoginController.cs
index 7765cb673..af11d4000 100644
--- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/LoginController.cs
+++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Controllers/LoginController.cs
@@ -1246,6 +1246,10 @@ namespace Learun.Application.Web.Controllers
{
return Fail("用户手机号不存在!");
}
+ if (!CommonHelper.IsValidMobile(userEntity.F_Mobile))
+ {
+ return Fail("手机号格式不正确!");
+ }
if (codeType == "firstlogin" && userEntity.F_HaveLogMark == true)
{
return Fail("当前用户非首次登录,请使用账号密码进行登录!");
diff --git a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/UserApi.cs b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/UserApi.cs
index 6b08ba801..5d8a32c2f 100644
--- a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/UserApi.cs
+++ b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/UserApi.cs
@@ -113,6 +113,10 @@ namespace Learun.Application.WebApi
{
return Fail("手机号不能为空。");
}
+ if (!CommonHelper.IsValidMobile(loginModel.username))
+ {
+ return Fail("手机号格式不正确!");
+ }
//todo:待取消注释
//string raRndNum = Learun.Util.CommonHelper.RndNum(6);
string raRndNum = "123456";
diff --git a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/UsernologinApi.cs b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/UsernologinApi.cs
index d6f30f2bd..f11bb6313 100644
--- a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/UsernologinApi.cs
+++ b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/UsernologinApi.cs
@@ -104,6 +104,10 @@ namespace Learun.Application.WebApi
{
return Fail("用户手机号不存在!");
}
+ if (!CommonHelper.IsValidMobile(userEntity.F_Mobile))
+ {
+ return Fail("手机号格式不正确!");
+ }
if (loginModel.codeType == "firstlogin" && userEntity.F_HaveLogMark == true)
{
return Fail("当前用户非首次登录,请使用账号密码进行登录!");
diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Common/CommonHelper.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Common/CommonHelper.cs
index 9bf04161c..340f425bf 100644
--- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Common/CommonHelper.cs
+++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Util/Learun.Util/Common/CommonHelper.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
+using System.Text.RegularExpressions;
namespace Learun.Util
{
@@ -145,5 +146,19 @@ namespace Learun.Util
return str;
}
#endregion
+
+ #region 验证字符串的格式
+
+ ///
+ /// 是否是手机格式
+ ///
+ ///
+ ///
+ public static bool IsValidMobile(string mobile)
+ {
+ return Regex.IsMatch(mobile, @"^(\+\d{2,3}\-)?\d{11}$");
+ }
+
+ #endregion
}
}