Browse Source

修改密码规则

heyiwen 5 days ago
parent
commit
293639e160

+ 1 - 1
EMIS.CommonLogic/DataCenterSynch/StudentSynchServices.cs

@@ -141,7 +141,7 @@ namespace EMIS.CommonLogic.DataCenterSynch
                         {
                             UserID = userID,
                             LoginID = SFZJH,
-                            Password = "888888".MD5(),
+                            Password = ("Ab!" + SFZJH.Substring(SFZJH.Length - 6)).MD5(),
                             Name = XM,
                             RecordStatus = (int)SYS_STATUS.USABLE,
                             CreateTime = nowTime,

+ 4 - 7
EMIS.CommonLogic/Students/StudentsServices.cs

@@ -1432,9 +1432,7 @@ namespace EMIS.CommonLogic.Students
                 StudentID.Add(user.UserID);
                 if (parameter == null)
                 {
-
-                    //密码默认为6个8
-                    user.Password = ("888888").MD5();
+                    user.Password = ("Ab!" + studentfileView.IDNumber.Substring(studentfileView.IDNumber.Length - 6)).MD5();
                 }
                 else
                 {
@@ -1444,8 +1442,7 @@ namespace EMIS.CommonLogic.Students
                     }
                     else
                     {
-                        //密码默认为6个8
-                        user.Password = ("888888").MD5();
+                        user.Password = ("Ab!" + studentfileView.IDNumber.Substring(studentfileView.IDNumber.Length - 6)).MD5();
                     }
                 }
                 user.CreateTime = DateTime.Now;
@@ -1760,7 +1757,7 @@ namespace EMIS.CommonLogic.Students
                 if (parameter == null)
                 {
 
-                    pwd = ("888888").MD5();
+                    pwd = ("Ab!" + studentfileView[i].IDNumber.Substring(studentfileView[i].IDNumber.Length - 6)).MD5();
                 }
                 else
                 {
@@ -1770,7 +1767,7 @@ namespace EMIS.CommonLogic.Students
                     }
                     else
                     {
-                        pwd = ("888888").MD5();
+                        pwd = ("Ab!" + studentfileView[i].IDNumber.Substring(studentfileView[i].IDNumber.Length - 6)).MD5();
                     }
                 }
                 Sys_User user=new Sys_User();

+ 6 - 1
EMIS.CommonLogic/SystemServices/UserServices.cs

@@ -40,6 +40,7 @@ namespace EMIS.CommonLogic.SystemServices
         public StudentsDAL StudentsDAL { get; set; }
 
         public EMIS.DataLogic.Repositories.HRService.UsersRepository CommUserRepository { get; set; }
+        public WechatMPDAL WechatMPDAL { get; set; }
 
         public Lazy<IControlItemServices> ControlItemServices { get; set; }
 
@@ -352,6 +353,7 @@ namespace EMIS.CommonLogic.SystemServices
                 if (isChange == false)
                 {
                     List<Sys_User> list = UserDAL.UserRepository.Entities.Where(x => userID.Contains(x.UserID)).ToList();
+                    List<CF_WechatSubscribe> wechatList = WechatMPDAL.WechatSubscripbeRepository.Entities.Where(x => userID.Contains(x.UserID)).ToList();
                     List<CF_Student> studentList = StudentsDAL.StudentRepository.Entities.Where(x => userID.Contains(x.UserID)).ToList();
                     List<CF_Staff> staffList = StaffDAL.staffRepository.Entities.Where(x => userID.Contains(x.UserID)).ToList();
                     List<Sys_User> userList = new List<Sys_User>();
@@ -362,6 +364,7 @@ namespace EMIS.CommonLogic.SystemServices
                             var student = studentList.Where(x => x.UserID == user.UserID).FirstOrDefault();
                             var passwordstr = "Ab!" + student.IDNumber.Substring(student.IDNumber.Length - 6);
                             user.Password = passwordstr.MD5();
+                            
                             SetModifyStatus(user);
                             userList.Add(user);
                         }
@@ -378,7 +381,7 @@ namespace EMIS.CommonLogic.SystemServices
                         }
                     }
 
-
+                    UnitOfWork.Delete(wechatList);
                     UnitOfWork.BatchUpdate(userList);
                     UnitOfWork.Commit();
                 }
@@ -390,6 +393,7 @@ namespace EMIS.CommonLogic.SystemServices
                     }
 
                     List<Sys_User> list = UserDAL.UserRepository.Entities.Where(x => userID.Contains(x.UserID)).ToList();
+                    List<CF_WechatSubscribe> wechatList = WechatMPDAL.WechatSubscripbeRepository.Entities.Where(x => userID.Contains(x.UserID)).ToList();
                     List<Sys_User> userList = new List<Sys_User>();
                     foreach (var user in list)
                     {
@@ -397,6 +401,7 @@ namespace EMIS.CommonLogic.SystemServices
                         SetModifyStatus(user);
                         userList.Add(user);
                     }
+                    UnitOfWork.Delete(wechatList);
                     UnitOfWork.BatchUpdate(userList);
                     UnitOfWork.Commit();
                 }

+ 1 - 0
EMIS.ViewModel/EMIS.ViewModel.csproj

@@ -187,6 +187,7 @@
     <Compile Include="Students\StudentRecordView.cs" />
     <Compile Include="SystemView\BatchInitPasswordView.cs" />
     <Compile Include="SystemView\ContextMenuNoView.cs" />
+    <Compile Include="SystemView\MobileLoginView.cs" />
     <Compile Include="SystemView\RegistView.cs" />
     <Compile Include="SystemView\StandardView.cs" />
     <Compile Include="TestOperateView.cs" />

+ 1 - 0
EMIS.ViewModel/SystemView/BatchInitPasswordView.cs

@@ -26,6 +26,7 @@ namespace EMIS.ViewModel.SystemView
         /// </summary>
         //[RegularExpression(@"^(?=.*[0-9].*)(?=.*[a-zA-Z].*).{6,16}$", ErrorMessage = "请输入包含字母加数字的密码,6-16位")]
         [DisplayName("自定义密码")]
+        [RegularExpression("^(?=.*?[0-9])(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[#?!@$%^&*-]).{8,}$", ErrorMessage = "密码须包含大小写英文、特殊字符、数字且长度大于或等于8位")]
         public string Password { get; set; }
     }
 }

+ 0 - 1
EMIS.ViewModel/SystemView/ChangePasswordView.cs

@@ -17,7 +17,6 @@ namespace EMIS.ViewModel.SystemView
 
         [Required]
         [DataType(DataType.Password)]
-        [StringLength(50, ErrorMessage = "密码长度不能小于6位", MinimumLength = 8)]
         [RegularExpression("^(?=.*?[0-9])(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[#?!@$%^&*-]).{8,}$", ErrorMessage = "密码须包含大小写英文、特殊字符、数字且长度大于或等于8位")]
         [DisplayName("新密码")]
         public string Password { get; set; }

+ 14 - 0
EMIS.ViewModel/SystemView/MobileLoginView.cs

@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace EMIS.ViewModel.SystemView
+{
+    public class MobileLoginView
+    {
+        public string loginID { get; set; }
+        public string password { get; set; }
+        public string openID { get; set; }
+    }
+}

+ 1 - 1
EMIS.ViewModel/SystemView/RegistView.cs

@@ -27,7 +27,7 @@ namespace EMIS.ViewModel.SystemView
         [DataType(DataType.Password)]
         [DisplayName("密码")]
         //[StringLength(50, ErrorMessage = "密码长度不能小于6位", MinimumLength = 6)]
-        [RegularExpression(@"^(?=.*[0-9])(?=.*[a-zA-Z]).{6,}$", ErrorMessage = "密码必须包含英文、数字,且长度大于等于6位")]
+        [RegularExpression("^(?=.*?[0-9])(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[#?!@$%^&*-]).{8,}$", ErrorMessage = "密码须包含大小写英文、特殊字符、数字且长度大于或等于8位")]
         public string PCode { get; set; }
         [Required(ErrorMessage = "请再次输入密码。")]
         [DisplayName("密码确认")]

+ 1 - 1
EMIS.Web/Controllers/HomeController.cs

@@ -24,7 +24,7 @@ namespace EMIS.Web.Controllers
         public IAnnouncementServices AnnouncementServices { get; set; }
         public ActionResult Index()
         {
-            var IsStudent = EMIS.Utility.FormValidate.CustomPrincipal.Current.IsStudent;
+            var IsStudent = CustomPrincipal.Current != null ? CustomPrincipal.Current.IsStudent : false;
             ViewBag.IsStudent = IsStudent; 
 
             if (IsStudent)

+ 3 - 1
EMIS.Web/Scripts/Business/Common/Login.js

@@ -23,10 +23,12 @@
 function loginProcess() {
     $(".loginbutton")[0].innerText = "      登 录 中...   ";
     var reg = /^(?=.*?[0-9])(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[#?!@$%^&*-]).{8,}$/g;
+    $("#NeedChangePwd").val("false");
+    $("#NeedChangePwdReason").val("");
     if (!reg.test($("#Password").val())) {
         $("#NeedChangePwd").val("true");
         $("#NeedChangePwdReason").val("密码须包含大小写英文、特殊字符、数字且长度大于或等于8位");
-    }
+    } 
     if ($("#Password").val() == "Ab#888888") {
         $("#NeedChangePwd").val("true");
         $("#NeedChangePwdReason").val("你在重置密码后首次登录");

+ 73 - 15
EMIS.Web/ServiceControllers/SystemManage/UserServicesController.cs

@@ -8,6 +8,11 @@ using System.Web.Mvc;
 using EMIS.Web.Controls;
 using EMIS.ViewModel;
 using EMIS.ViewModel.SystemView;
+using Bowin.Web.Controls.Mvc;
+using EMIS.Utility;
+using Bowin.Common.Utility;
+using System.Web.Http;
+using System.Configuration;
 
 namespace EMIS.Web.ServiceControllers.SystemManage
 { 
@@ -20,32 +25,40 @@ namespace EMIS.Web.ServiceControllers.SystemManage
         public IWechatMPServices WechatMPServices { get; set; }
         public IMailVerifyServices MailVerifyServices { get; set; }
 
-
+        [System.Web.Http.HttpPost]
         public ActionResult Login(string loginID, string password, string openID)
         {
+            if (loginID == null)
+            {
+                return Json(new ReturnMessage { IsSuccess = false, Message = "没有接收loginid" });
+            }
+
             password = Bowin.Common.Utility.StringEx.MD5(password);
             var isLogined = UserServices.Login(loginID, password);
             bool isCanLogin = UserServices.LoginHistory(loginID, isLogined);
-            
-            try
+
+            if (ConfigurationManager.AppSettings["WeixinOnDebug"] != "1")
             {
-                if (!isCanLogin)
-                {
-                    throw new Exception("当天登陆失败次数超过5次,请明天再试或联系管理员。");
-                }
-                if (openID != null && openID != "null")
+                try
                 {
-                    WechatMPServices.BindOpenID(loginID, openID);
+                    if (!isCanLogin)
+                    {
+                        throw new Exception("当天登陆失败次数超过5次,请明天再试或联系管理员。");
+                    }
+                    if (openID != null && openID != "null")
+                    {
+                        WechatMPServices.BindOpenID(loginID, openID);
+                    }
+                    else if (openID == "null")
+                    {
+                        throw new Exception("微信openid获取失败,请关注公众号之后,刷新页面重试!如果已经关注公众号,请联系老师或管理员。");
+                    }
                 }
-                else if (openID == "null")
+                catch (Exception ex)
                 {
-                    throw new Exception("微信openid获取失败,请关注公众号之后,刷新页面重试!如果已经关注公众号,请联系老师或管理员。");
+                    return Json(new ReturnMessage { IsSuccess = false, Message = ex.Message });
                 }
             }
-            catch(Exception ex)
-            {
-                return Json(new ReturnMessage { IsSuccess = false, Message = ex.Message });
-            }
             return Json(new ReturnMessage { IsSuccess = isLogined, Message = "密码错误或不存在该账户!(注意:如密码连续输入错误5次以上账号将被锁定)" });  
         }
          
@@ -99,6 +112,51 @@ namespace EMIS.Web.ServiceControllers.SystemManage
             }
         }
 
+        public ActionResult GetSchoolAreaWithoutSocial(DropdownListBindType? bindType)
+        {
+            List<DropdownListItem> list = DictionaryHelper.GetDictionaryValue(DictionaryItem.CF_SchoolArea)
+                .Where(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && x.Value < 3)
+                .Select(x => new DropdownListItem { Text = x.Name, Value = x.Value.ToString() }).ToList();
+            DropdownListBindType dbt = bindType == null ? DropdownListBindType.SelectAll : bindType.Value;
+
+            DropdownList.FormatDropdownItemList(dbt, list);
+
+            return base.Json(list);
+        }
+
+        [System.Web.Http.HttpPost]
+        public ActionResult ChangePassword(ChangePasswordView changePasswordView, Guid userID)
+        {
+            try
+            {
+                var user = UserServices.GetUserByID(userID);
+                if (user.Password.ToLower() != changePasswordView.OldPassword.MD5().ToLower())
+                {
+                    return Json(new ReturnMessage()
+                    {
+                        IsSuccess = false,
+                        Message = "保存失败:原密码验证失败"
+                    });
+                }
+
+                UserServices.ChangePassword(changePasswordView, user.UserID);
+
+                return Json(new ReturnMessage()
+                {
+                    IsSuccess = true,
+                    Message = "密码已经成功修改!"
+                });
+            }
+            catch (Exception ex)
+            {
+                return Json(new ReturnMessage()
+                {
+                    IsSuccess = false,
+                    Message = "保存失败:" + ex.Message
+                });
+            }
+        }
+
         //[HttpPost]
         //public ActionResult ForgotPassword(string LoginID)
         //{

+ 4 - 0
EMIS.Web/Views/Account/ChangePassword.cshtml

@@ -7,6 +7,10 @@
 @section scripts{
     <script language="javascript">
         function Password_Save() {
+            if ($("#OldPassword").val() == $("#Password").val()) {
+                $.messager.alert('系统提示', '新密码不能和旧密码相同', 'info');
+                return;
+            }
             if ($("#Password").val() != $("#PasswordRep").val()) {
                 $.messager.alert('系统提示', '两次输入的密码必须一致', 'info');
                 return;

+ 1 - 1
EMIS.Web/Views/Account/Regist.cshtml

@@ -53,7 +53,7 @@
                 </tr>
                 <tr>
                     <td colspan="2" style="background-color: white">
-                        <font color="red">密码必须包含英文、数字,且长度大于等于6位</font>
+                        <font color="red">密码须包含大小写英文、特殊字符、数字且长度大于或等于8位</font>
                     </td>
                 </tr>
                 <tr>

+ 4 - 0
EMIS.Web/Views/Home/MainChangePwd.cshtml

@@ -22,6 +22,10 @@
 @section scripts{
     <script type="text/javascript">
         function Password_Save() {
+            if ($("#OldPassword").val() == $("#Password").val()) {
+                $.messager.alert('系统提示', '新密码不能和旧密码相同', 'info');
+                return;
+            }
             if ($("#Password").val() != $("#PasswordRep").val()) {
                 $.messager.alert('系统提示', '两次输入的密码必须一致', 'info');
                 return;

+ 4 - 0
EMIS.Web/Web.config

@@ -125,6 +125,9 @@
       <customHeaders>
         <clear />
         <add name="X-UA-Compatible" value="IE=8" />
+        <add name="Access-Control-Allow-Origin" value="*"/>
+        <add name="Access-Control-Allow-Headers" value="*"/>
+        <add name="Access-Control-Allow-Methods" value="GET,POST,OPTIONS"/>
       </customHeaders>
     </httpProtocol>
     <security>
@@ -362,6 +365,7 @@
       <!-- 微信公众号URL对接信息 -->
       <add key="WeixinToken" value="chuangxin1234567chuangxin1234567" />
       <add key="WeixinEncodingAESKey" value="" />
+      <add key="WeixinOnDebug" value="1"/>
       <!-- 高级接口信息 -->
       <add key="WeixinAppId" value="wx1932067a4e356125" />
       <add key="WeixinAppSecret" value="e9ad9550755af983703d97bb09c64c51" />