Beispiel #1
0
        public IActionResult ChangePassword(CHIS.Models.ViewModel.ChangeLoginInfo model)
        {
            try
            {
                if (model.MyPswd != model.MyPswdConfirm)
                {
                    throw new Exception("密码验证错误");
                }
                if (model.VarifyType == "mobile")
                {
                    if (!new SendVCodeCBL(this).VerifyCheck(model.MobileNumber, model.MobileNumberVCode))
                    {
                        throw new Exception("手机验证码验证错误");
                    }
                    var find = _db.CHIS_Sys_Login.FirstOrDefault(m => m.Mobile == model.MobileNumber);
                    find.LoginPassword = model.MyPswd;
                    _db.SaveChanges();
                }
                else if (model.VarifyType == "email")
                {
                    if (!new SendVCodeCBL(this).VerifyCheck(model.Email, model.EmailVCode))
                    {
                        throw new Exception("邮箱验证码验证错误");
                    }
                    var find = _db.CHIS_Sys_Login.FirstOrDefault(m => m.Email == model.Email);
                    find.LoginPassword = model.MyPswd;
                    _db.SaveChanges();
                }
                else if (model.VarifyType == "idcard")
                {
                    if (model.IDCard.IsEmpty())
                    {
                        throw new Exception("没有输入身份证号码");
                    }
                    var find = _db.CHIS_Sys_Login.FirstOrDefault(m => m.IdCardNumber == model.IDCard);
                    if (find == null)
                    {
                        throw new Exception("没有发现此身份证的登录信息");
                    }
                    if (find.LoginPassword != model.OrigPswd)
                    {
                        throw new Exception("密码验证错误");
                    }

                    find.LoginPassword = model.MyPswd;
                    _db.SaveChanges();
                }
                else
                {
                    throw new Exception("不支持的修改类型");
                }
                return(View("AdoptSuccess"));//返回成功页面
            }
            catch (Exception ex) { return(View("Error", ex)); }
        }
Beispiel #2
0
        public IActionResult ChangeMobile2(CHIS.Models.ViewModel.ChangeLoginInfo model)
        {
            try
            {
                switch (model.VarifyType.ToLower())
                {
                case "mobile":
                    if (!new SendVCodeCBL(this).VerifyCheck(model.MobileNumber, model.MobileNumberVCode))
                    {
                        ModelState.AddModelError("", "手机验证码校验错误");
                    }
                    break;

                case "email":
                    if (!new SendVCodeCBL(this).VerifyCheck(model.Email, model.EmailVCode))
                    {
                        ModelState.AddModelError("", "邮箱验证码校验错误");
                    }
                    break;

                case "idcard":
                    break;

                default: throw new Exception("验证方式传入错误");
                }
            }
            catch (Exception ex) { ModelState.AddModelError("", ex.Message); }
            if (!ModelState.IsValid)
            {
                return(ChangeMobile());
            }
            var orig_Mobile = _db.CHIS_Sys_Login.FirstOrDefault(m => m.DoctorId == this.UserSelf.DoctorId).Mobile;

            ViewBag.OriginalMobile = orig_Mobile;
            ViewBag.CheckCode      = Ass.Data.Secret.Encript(orig_Mobile, Global.SYS_ENCRIPT_PWD);
            return(View());
        }