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 } }