示例#1
0
        public async Task <IActionResult> ResetPassword(string userId)
        {
            CommonResult result = new CommonResult();

            try
            {
                string where = string.Format("UserId='{0}'", userId);
                UserLogOn userLogOn = userLogOnService.GetWhere(where);
                Random    random    = new Random();
                string    strRandom = random.Next(100000, 999999).ToString(); //生成编号
                userLogOn.UserSecretkey      = MD5Util.GetMD5_16(GuidUtils.NewGuidFormatN()).ToLower();
                userLogOn.UserPassword       = MD5Util.GetMD5_32(DEncrypt.Encrypt(MD5Util.GetMD5_32(strRandom).ToLower(), userLogOn.UserSecretkey).ToLower()).ToLower();
                userLogOn.ChangePasswordDate = DateTime.Now;
                bool bl = await userLogOnService.UpdateAsync(userLogOn, userLogOn.Id);

                if (bl)
                {
                    result.ErrCode = ErrCode.successCode;
                    result.ErrMsg  = strRandom;
                    result.Success = true;
                }
                else
                {
                    result.ErrMsg  = ErrCode.err43002;
                    result.ErrCode = "43002";
                }
            }catch (Exception ex)
            {
                Log4NetHelper.Error("重置密码异常", ex);//错误记录
                result.ErrMsg = ex.Message;
            }
            return(ToJsonContent(result));
        }
        //todo unitested
        public void UpdatePassword(int id, string oldPassword, string newPassword, string reNewPassword)
        {
            string enOldPwd = DEncrypt.Encrypt(oldPassword, Key);
            string enNewPwd = DEncrypt.Encrypt(newPassword, Key);

            if (newPassword != reNewPassword)
            {
                throw new BussinessException(ERROR_TWO_INPUT_PASSWORD_DIFFERENT);
            }

            if (newPassword.Length >= 32)
            {
                throw new BussinessException(ERROR_PWD_LEN_MORE_THAN_32);
            }

            var user = GetUser(id);

            if (user.Password != enOldPwd)
            {
                throw new BussinessException(ERROR_USERNAME_OR_PASSWORD);
            }

            if (user.Password == enNewPwd)
            {
                throw new BussinessException(ERROR_NEW_OLD_PASSOWRD_SAME);
            }

            _userDao.UpdatePassword(id, enNewPwd);
        }
示例#3
0
        public ActionResult Loginaction()
        {
            string login_username = Request.Form["login_username"].ToString().Trim();
            string login_password = DEncrypt.Encrypt(Request.Form["login_password"].ToString().Trim());

            Psd.H5Show.BLL.user_account userAccountBll = new Psd.H5Show.BLL.user_account();

            List <Psd.H5Show.Model.user_account> userAccountModelList =
                userAccountBll.GetModelList(
                    string.Format("STATE='1' and DELFLAG='0' and UserCode='{0}' and `Password` ='{1}'", login_username,
                                  login_password));

            if (userAccountModelList.Count > 0)
            {
                msgModel.Result = 1;
                msgModel.Msg    = "登录成功";
                HttpCookie cookie = new HttpCookie("PsdH5ShowUserCode");
                cookie.Value   = DEncrypt.Encrypt(userAccountModelList[0].UserCode);
                cookie.Expires = DateTime.Now.AddDays(1);
                HttpContext.Response.Cookies.Add(cookie);
            }
            else
            {
                msgModel.Result = 0;
                msgModel.Msg    = "账号或密码错误";
            }
            JsonResult Js = new JsonResult();

            Js.Data = msgModel;
            Js.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            return(Js);
        }
示例#4
0
        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            // 1. 这里放置保存窗体中数据的逻辑
            var bllxs = BLL.TcAdmin.Instance;
            var mxs   = id > 0 ? bllxs.GetModel(id) : new Model.TcAdmin();

            if (mxs == null)
            {
                mxs = new Model.TcAdmin();
            }
            mxs.Name = txt_title.Text.Trim().GetString();

            string pwd  = txt_pwd.Text.Trim();
            string pwd2 = txt_pwd2.Text.Trim();

            if (pwd == pwd2)
            {
                mxs.Pwd = DEncrypt.Encrypt(pwd);

                var dt = bllxs.GetList("name='" + mxs.Name + "'").Tables[0];
                if (id > 0)
                {
                    if (dt.Rows.Count > 0)
                    {
                        var i = dt.Rows[0]["id"].GetString().GetInt();
                        if (i != id)
                        {
                            Alert("登录名已经存在!");
                        }
                        else
                        {
                            bllxs.Update(mxs);//更新
                            Alert("保存成功!");
                        }
                    }
                    else
                    {
                        bllxs.Update(mxs);//更新
                        Alert("保存成功!");
                    }
                }
                else
                {
                    mxs.Role = 2;
                    if (dt.Rows.Count > 0)
                    {
                        Alert("登录名已经存在!");
                    }
                    else
                    {
                        bllxs.Add(mxs);//添加
                        Alert("保存成功!");
                    }
                }
            }
            else
            {
                Alert("两次密码输入不一致!");
            }
        }
        public IActionResult YuebonConnecSys(string systype)
        {
            CommonResult result = new CommonResult();

            try
            {
                if (!string.IsNullOrEmpty(systype))
                {
                    SystemType        systemType        = iService.GetByCode(systype);
                    string            openmf            = MD5Util.GetMD5_32(DEncrypt.Encrypt(CurrentUser.UserId + systemType.Id, GuidUtils.NewGuidFormatN())).ToLower();
                    YuebonCacheHelper yuebonCacheHelper = new YuebonCacheHelper();
                    TimeSpan          expiresSliding    = DateTime.Now.AddSeconds(20) - DateTime.Now;
                    yuebonCacheHelper.Add("openmf" + openmf, CurrentUser.UserId, expiresSliding, false);
                    result.ErrCode = ErrCode.successCode;
                    result.ResData = systemType.Url + "?openmf=" + openmf;
                }
                else
                {
                    result.ErrCode = ErrCode.failCode;
                    result.ErrMsg  = "切换子系统参数错误";
                }
            }
            catch (Exception ex)
            {
                Log4NetHelper.Error("切换子系统异常", ex);
                result.ErrMsg  = ErrCode.err40110;
                result.ErrCode = "40110";
            }
            return(ToJsonContent(result));
        }
示例#6
0
        private ActionResult LoginMethod(User model, MyDbContext db, string returnurl)
        {
            Token t = new Token
            {
                ExpTime  = DateTime.Now.AddMinutes(2),
                IsEnable = true,
                UserName = model.UserName
            };

            db.Token.Add(t);
            db.SaveChanges();

            string token = DEncrypt.Encrypt <Token>(t);
            //写入一个cookie,标识登陆成功
            HttpCookie c = new HttpCookie(CommonHelper.LoginCookieName, DEncrypt.Encrypt(model.UserName));

            c.Expires = DateTime.Now.AddDays(7);
            if (Request.Cookies[CommonHelper.LoginCookieName] == null)
            {
                Response.Cookies.Add(c);
            }
            else
            {
                Response.Cookies.Set(c);
            }

            string url = DEncrypt.Decrypt(returnurl);

            return(Redirect(url + "?token=" + Server.UrlEncode(token)));
        }
示例#7
0
        protected void ImageButton1_Click(object sender, EventArgs e)
        {
            string pwd     = txt_oldpwd.Text.Trim();
            string newpwd  = txt_newpwd.Text.Trim();
            string newpwd2 = txt_newpwd2.Text.Trim();

            if (newpwd == newpwd2)
            {
                BLL.TcAdmin ado = new BLL.TcAdmin();

                if (DEncrypt.Encrypt(pwd).ToLower() == My.Pwd.ToLower())
                {
                    if (txt_title.Text.Trim().Length > 0)
                    {
                        My.Name = txt_title.Text;
                    }
                    My.Pwd = DEncrypt.Encrypt(newpwd);
                    ado.Update(My);
                    Session[LibAdmin.Session_admin] = My;
                    Alert("保存成功!");
                }
                else
                {
                    Alert("原密码错误!");
                }
            }
            else
            {
                Alert("两次密码不一致!");
            }
        }
示例#8
0
 public ActionResult UserAdd(UserInfo info)
 {
     if (string.IsNullOrEmpty(info.ID))
     {
         info.ID       = GuidHelper.GetUniqueID();
         info.Password = DEncrypt.Encrypt(info.Password);
         if (UserService.Insert <UserInfo>(info))
         {
             Result.IsOk = true;
             Result.Msg  = "添加成功";
         }
         else
         {
             Result.IsOk = false;
             Result.Msg  = "添加失败";
         }
     }
     else
     {
         if (UserService.Update <UserInfo>(info))
         {
             Result.IsOk = true;
             Result.Msg  = "更新成功";
         }
         else
         {
             Result.IsOk = false;
             Result.Msg  = "更新失败";
         }
     }
     Result.RedirectUrl = "/User/UserList";
     return(Json(Result));
 }
示例#9
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string name = this.txt_name.Text.Replace("'", "").FilterSql();
            string pwd  = DEncrypt.Encrypt(this.txt_pwd.Text.FilterSql());

            if (name.Length > 0 && pwd.Length > 0)
            {
                Tc.BLL.TcAdmin          ao = new Tc.BLL.TcAdmin();
                List <Tc.Model.TcAdmin> t  = ao.GetModelList("name='" + name + "'");
                if (t.Count <= 0)
                {
                    ClientScript.RegisterClientScriptBlock(this.GetType(), "login", "alert('用户名或密码错误!请重新尝试!')", true);
                }
                else
                {
                    if (t[0].Pwd.GetString().ToLower() == pwd.ToLower())
                    {
                        Session[LibAdmin.Session_admin] = t[0];

                        Response.Redirect("main.aspx");
                    }

                    else
                    {
                        ClientScript.RegisterClientScriptBlock(this.GetType(), "login", "alert('用户名或密码错误!请重新尝试')", true);
                    }
                }
            }
            else
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "login", "alert('请输入用户名和密码')", true);
            }
        }
示例#10
0
        public async Task <IActionResult> ModifyPassword(string oldpassword, string password, string password2)
        {
            CommonResult result = new CommonResult();

            try
            {
                if (string.IsNullOrEmpty(oldpassword))
                {
                    result.ErrMsg = "原密码不能为空!";
                }
                else if (string.IsNullOrEmpty(password))
                {
                    result.ErrMsg = "密码不能为空!";
                }
                else if (string.IsNullOrEmpty(password2))
                {
                    result.ErrMsg = "重复输入密码不能为空!";
                }
                else if (password == password2)
                {
                    var    userSinginEntity = userLogOnService.GetByUserId(CurrentUser.UserId);
                    string inputPassword    = MD5Util.GetMD5_32(DEncrypt.Encrypt(MD5Util.GetMD5_32(oldpassword).ToLower(), userSinginEntity.UserSecretkey).ToLower()).ToLower();
                    if (inputPassword != userSinginEntity.UserPassword)
                    {
                        result.ErrMsg = "原密码错误!";
                    }
                    else
                    {
                        string where = string.Format("UserId='{0}'", CurrentUser.UserId);
                        UserLogOn userLogOn = userLogOnService.GetWhere(where);

                        userLogOn.UserSecretkey      = MD5Util.GetMD5_16(GuidUtils.NewGuidFormatN()).ToLower();
                        userLogOn.UserPassword       = MD5Util.GetMD5_32(DEncrypt.Encrypt(MD5Util.GetMD5_32(password).ToLower(), userLogOn.UserSecretkey).ToLower()).ToLower();
                        userLogOn.ChangePasswordDate = DateTime.Now;
                        bool bl = await userLogOnService.UpdateAsync(userLogOn, userLogOn.Id);

                        if (bl)
                        {
                            result.ErrCode = ErrCode.successCode;
                        }
                        else
                        {
                            result.ErrMsg  = ErrCode.err43002;
                            result.ErrCode = "43002";
                        }
                    }
                }
                else
                {
                    result.ErrMsg = "两次输入的密码不一样";
                }
            }
            catch (Exception ex)
            {
                Log4NetHelper.Error("重置密码异常", ex);//错误记录
                result.ErrMsg = ex.Message;
            }
            return(ToJsonContent(result));
        }
        public int User_Edit(VolunteerAddViewModel VuserAddViewModel)
        {
            DEncrypt encrypt   = new DEncrypt();
            var      user_Info = _IMapper.Map <VolunteerAddViewModel, Volunteer_Info>(VuserAddViewModel);

            // 字段加密 20200521
            user_Info.Name          = encrypt.Encrypt(user_Info.Name);
            user_Info.CertificateID = encrypt.Encrypt(user_Info.CertificateID);
            user_Info.Mobile        = encrypt.Encrypt(user_Info.Mobile);

            _IVolunteerInfoRepository.EditInfo(user_Info);
            int a = _IVolunteerInfoRepository.SaveChanges();

            //保存完善信息(擅长技能、服务领域)   先删除原有信息在添加
            _IVolunteer_Relate_TypeRepository.RemoveAll(user_Info.ID);

            List <Volunteer_Relate_TypeMiddle> Relate_Types = VuserAddViewModel.RelateUserIDandTypeIDList;
            var TypeInfo = _IMapper.Map <List <Volunteer_Relate_TypeMiddle>, List <Volunteer_Relate_Type> >(Relate_Types);

            foreach (var itme in TypeInfo)
            {
                _IVolunteer_Relate_TypeRepository.Add(itme);
                int b = _IVolunteer_Relate_TypeRepository.SaveChanges();
            }


            //保存 资质文件信息 先删除原有信息在添加

            _IVAttachmentRepository.RemoveAll(user_Info.ID, "ZZFJ");
            List <VAttachmentAddViewModel> VAttachmentAdds = VuserAddViewModel.VAttachmentAddList;
            var AttachmentInfo = _IMapper.Map <List <VAttachmentAddViewModel>, List <VAttachment> >(VAttachmentAdds);

            foreach (var item in AttachmentInfo)
            {
                item.ID         = Guid.NewGuid().ToString();
                item.formid     = VuserAddViewModel.ID;
                item.type       = "ZZFJ";
                item.Status     = "0";
                item.CreateUser = VuserAddViewModel.ID;
                item.CreateDate = DateTime.Now;
                _IVAttachmentRepository.Add(item);
                int c = _IVAttachmentRepository.SaveChanges();
            }

            return(a);
        }
示例#12
0
 /// <summary>
 /// 注册用户
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="userLogOnEntity"></param>
 /// <param name="trans"></param>
 public bool Insert(User entity, UserLogOn userLogOnEntity, IDbTransaction trans = null)
 {
     userLogOnEntity.Id            = GuidUtils.CreateNo();
     userLogOnEntity.UserId        = entity.Id;
     userLogOnEntity.UserSecretkey = MD5Util.GetMD5_16(GuidUtils.NewGuidFormatN()).ToLower();
     userLogOnEntity.UserPassword  = MD5Util.GetMD5_32(DEncrypt.Encrypt(MD5Util.GetMD5_32(userLogOnEntity.UserPassword).ToLower(), userLogOnEntity.UserSecretkey).ToLower()).ToLower();
     DbContext.GetDbSet <User>().Add(entity);
     DbContext.GetDbSet <UserLogOn>().Add(userLogOnEntity);
     return(DbContext.SaveChanges() > 0);
 }
示例#13
0
 /// <summary>
 /// 注册租户
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="tenantLogOnEntity"></param>
 public async Task <bool> InsertAsync(Tenant entity, TenantLogon tenantLogOnEntity)
 {
     tenantLogOnEntity.Id              = GuidUtils.CreateNo();
     tenantLogOnEntity.TenantId        = entity.Id;
     tenantLogOnEntity.TenantSecretkey = MD5Util.GetMD5_16(GuidUtils.NewGuidFormatN()).ToLower();
     tenantLogOnEntity.TenantPassword  = MD5Util.GetMD5_32(DEncrypt.Encrypt(MD5Util.GetMD5_32(tenantLogOnEntity.TenantPassword).ToLower(), tenantLogOnEntity.TenantSecretkey).ToLower()).ToLower();
     DbContext.GetDbSet <Tenant>().Add(entity);
     DbContext.GetDbSet <TenantLogon>().Add(tenantLogOnEntity);
     return(await DbContext.SaveChangesAsync() > 0);
 }
        public void ResetPassword(int userId, string password)
        {
            if (password.Length >= 32)
            {
                throw new BussinessException(ERROR_PWD_LEN_MORE_THAN_32);
            }
            string enNewPwd = DEncrypt.Encrypt(password, Key);

            _userDao.UpdatePassword(userId, enNewPwd);
        }
示例#15
0
        public void EncryptTest()
        {
            string original = "我是谁";
            string expected = string.Empty; // TODO: 初始化为适当的值
            string actual;

            actual = DEncrypt.Encrypt(original);
            var result = DEncrypt.Decrypt(actual);

            Assert.AreEqual(original, result);
        }
        public User Login(string userName, string password)
        {
            string enPwd = DEncrypt.Encrypt(password, Key);
            var    user  = GetUserFromUserPo(_userDao.GetUserByUserNameAndPassword(userName, enPwd));

            if (!user.IsValid)
            {
                return(null);
            }
            return(user);
        }
示例#17
0
        public ActionResult Register(string usernamesignup, string passwordsignup)
        {
            S_User user = new S_User()
            {
                UserName   = usernamesignup,
                Password   = DEncrypt.Encrypt(passwordsignup, "zhang"),
                CreateTime = DateTime.Now
            };

            _iUserService.AddEntity(user);
            return(RedirectToAction("Index", "Home"));
        }
示例#18
0
 /// <summary>
 /// 用户登录
 /// </summary>
 /// <param name="userName"></param>
 /// <param name="password"></param>
 /// <returns></returns>
 public int UserLogin(string userName, string password, out UserInfo info)
 {
     info = GetModel <UserInfo>("UserName", userName);
     if (info == null)
     {
         return(RT.User_NotExist_UserName);
     }
     if (info.Password != DEncrypt.Encrypt(password))
     {
         return(RT.User_Error_Password);
     }
     return(RT.Success);
 }
示例#19
0
        public IActionResult Save(SysSetting info)
        {
            CommonResult result = new CommonResult();

            info.LocalPath = _hostingEnvironment.WebRootPath;
            SysSetting sysSetting = XmlConverter.Deserialize <SysSetting>("xmlconfig/sys.config");

            sysSetting = info;
            //对关键信息加密
            if (!string.IsNullOrEmpty(info.Email))
            {
                sysSetting.Email = DEncrypt.Encrypt(info.Email);
            }
            if (!string.IsNullOrEmpty(info.Emailsmtp))
            {
                sysSetting.Emailsmtp = DEncrypt.Encrypt(info.Emailsmtp);
            }
            if (!string.IsNullOrEmpty(info.Emailpassword))
            {
                sysSetting.Emailpassword = DEncrypt.Encrypt(info.Emailpassword);
            }
            if (!string.IsNullOrEmpty(info.Smspassword))
            {
                sysSetting.Smspassword = DEncrypt.Encrypt(info.Smspassword);
            }
            if (!string.IsNullOrEmpty(info.Smsusername))
            {
                sysSetting.Smsusername = DEncrypt.Encrypt(info.Smsusername);
            }
            string uploadPath = _hostingEnvironment.WebRootPath + "/" + sysSetting.Filepath;

            if (!Directory.Exists(uploadPath))
            {
                Directory.CreateDirectory(uploadPath);
            }
            YuebonCacheHelper yuebonCacheHelper = new YuebonCacheHelper();

            if (yuebonCacheHelper.Exists("SysSetting"))
            {
                yuebonCacheHelper.Replace("SysSetting", sysSetting);
            }
            else
            {
                //写入缓存
                yuebonCacheHelper.Add("SysSetting", sysSetting);
            }
            XmlConverter.Serialize <SysSetting>(sysSetting, "xmlconfig/sys.config");
            result.ErrCode = ErrCode.successCode;
            return(ToJsonContent(result));
        }
示例#20
0
        /// <summary>
        /// 租户登陆验证。
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <param name="password">密码(第一次md5加密后)</param>
        /// <returns>验证成功返回用户实体,验证失败返回null|提示消息</returns>
        public async Task <Tuple <Tenant, string> > Validate(string userName, string password)
        {
            var userEntity = await _repository.GetByUserName(userName);

            if (userEntity == null)
            {
                return(new Tuple <Tenant, string>(null, "系统不存在该用户,请重新确认。"));
            }

            if (!userEntity.EnabledMark)
            {
                return(new Tuple <Tenant, string>(null, "该用户已被禁用,请联系管理员。"));
            }

            var userSinginEntity = _repositoryLogon.GetByTenantId(userEntity.Id);

            string inputPassword = MD5Util.GetMD5_32(DEncrypt.Encrypt(MD5Util.GetMD5_32(password).ToLower(), userSinginEntity.TenantSecretkey).ToLower()).ToLower();

            if (inputPassword != userSinginEntity.TenantPassword)
            {
                return(new Tuple <Tenant, string>(null, "密码错误,请重新输入。"));
            }
            else
            {
                TenantLogon userLogOn = _repositoryLogon.GetWhere("UserId='" + userEntity.Id + "'");
                if (userLogOn.AllowEndTime < DateTime.Now)
                {
                    return(new Tuple <Tenant, string>(null, "您的账号已过期,请联系系统管理员!"));
                }
                if (userLogOn.LockEndDate > DateTime.Now)
                {
                    string dateStr = userLogOn.LockEndDate.ToEasyStringDQ();
                    return(new Tuple <Tenant, string>(null, "当前被锁定,请" + dateStr + "登录"));
                }
                if (userLogOn.FirstVisitTime == null)
                {
                    userLogOn.FirstVisitTime = userLogOn.PreviousVisitTime = DateTime.Now;
                }
                else
                {
                    userLogOn.PreviousVisitTime = DateTime.Now;
                }
                userLogOn.LogOnCount++;
                userLogOn.LastVisitTime = DateTime.Now;
                userLogOn.TenantOnLine  = true;
                await _repositoryLogon.UpdateAsync(userLogOn, userLogOn.Id);

                return(new Tuple <Tenant, string>(userEntity, ""));
            }
        }
示例#21
0
        protected void btnLogin_Click(object sender, ImageClickEventArgs e)
        {
            #region 检查验证码
            if ((Session["CheckCode"] != null) && (Session["CheckCode"].ToString() != ""))
            {
                if (Session["CheckCode"].ToString().ToLower() != this.CheckCode.Value.ToLower())
                {
                    this.lblMsg.Text     = "所填写的验证码与所给的不符 !";
                    Session["CheckCode"] = null;
                    return;
                }
                else
                {
                    Session["CheckCode"] = null;
                }
            }
            else
            {
                Response.Redirect("/Manager/Login.aspx");
            }
            #endregion

            string userName         = PageValidate.InputText(txtUsername.Value.Trim(), 30);
            string password         = PageValidate.InputText(txtPass.Value.Trim(), 30);
            string passwordDencrypt = DEncrypt.Encrypt(password);
            try
            {
                var model = bllTSUSER.GetModelByWhere(t => t.CN_LOGIN_NAME == userName && t.CN_PASSWORD == passwordDencrypt);
                if (model == null)
                {
                    this.lblMsg.Text = "登陆失败: " + userName;
                }
                else
                {
                    Session["UserInfo"]   = model;
                    Session["ReallyName"] = model.CN_REALLY_NAME;
                    Session["LoginID"]    = model.CN_ID;
                    Session["LoginName"]  = model.CN_LOGIN_NAME;
                    Response.Redirect("/Manager/Main.aspx", true);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message);
            }
            finally
            {
            }
        }
示例#22
0
        /// <summary>
        /// 将信息加密保存到cookie
        /// </summary>
        /// <param name="accessor"></param>
        /// <param name="cookieValue"></param>
        /// <returns></returns>
        public static bool SetCookie(this HttpContext httpContext, string cookieValue, string cookieKey = CookieKey)
        {
            if (string.IsNullOrWhiteSpace(cookieValue) || string.IsNullOrWhiteSpace(cookieKey))
            {
                return(false);
            }
            httpContext.Response.Cookies.Append(CookieKey, DEncrypt.Encrypt(cookieValue), new CookieOptions()
            {
                Expires  = DateTime.Now.AddDays(30),
                HttpOnly = true,
                Secure   = false
            });

            return(true);
        }
        //todo unitested
        public int AddUser(User user)
        {
            var checkUser = _userDao.GetUser(user.UserName);

            //判断用户名是否存在
            if (!checkUser.IsNullOrEmpty())
            {
                throw new BussinessException(ERROR_USERNAME_EXIST);
            }

            user.Password = DEncrypt.Encrypt(user.Password, Key);

            Object obj = _userDao.AddUser(GetUserPoFromUser(user));

            return((int)obj);
        }
示例#24
0
        /// <summary>
        /// 登录验证
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public async Task <BaseResult> LoginCheck(LoginParam param, HttpContext context)
        {
            param.Password = DEncrypt.Encrypt(param.Password);
            var data = await _usersRep.FirstOrDefaultAsync(" and UserName=@UserName and Password=@Password", param);

            if (data != null)
            {
                context.SetCookie(param.UserName);
                SetUserInfoSession(param.UserName, data);
                return(new Success("登陆成功"));
            }
            else
            {
                return(new Fail("用户名或密码错误"));
            }
        }
示例#25
0
        public ActionResult Login(string userName, string userPsw, string loginkeeping)
        {
            string psw         = DEncrypt.Encrypt(userPsw, "zhang");
            S_User currentUser = _iUserService.GetEntity <S_User>(l => l.UserName == userName && l.Password == psw);

            if (currentUser != null)
            {
                //用户数据插入redis
                //using (RedisHashService service = new RedisHashService())
                //{
                //    service.SetEntryInHash("user", currentUser.id.ToString(), JsonConvert.SerializeObject(currentUser));
                //};
                if (loginkeeping != null)
                {
                    HttpCookie cookie = new HttpCookie("_token");
                    cookie.Values.Add("name", JsonConvert.SerializeObject(currentUser));
                    cookie.Expires = DateTime.Now.AddYears(2);
                    Response.Cookies.Add(cookie);
                }
                else
                {
                    HttpContext.Response.Cookies["_token"].Expires = DateTime.Now.AddDays(-1);
                }
                Session["CurrentUser"] = currentUser;
                if (this.HttpContext.Session["CurrentUrl"] == null)
                {
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    string url = this.HttpContext.Session["CurrentUrl"].ToString();
                    this.HttpContext.Session["CurrentUrl"] = null;
                    return(Redirect(url));
                }
            }
            else
            {
                ModelState.AddModelError("failed", "密码不正确");
                return(View(new S_User()
                {
                    UserName = userName
                }));
            }
        }
示例#26
0
        protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
        {
            try
            {
                var where = ExpressionExtension.CreateExpression <TSUSERInfo>();
                string     id    = Session["LoginID"].ToString();
                TSUSERInfo model = new TSUSERBLL().GetModelByID(id);

                if (model.CN_PASSWORD != DEncrypt.Encrypt(txtOldPwd.Text.Trim()))
                {
                    args.IsValid = false;
                    return;
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteErrorLog(ex);
                MessageBox.Show(this, "验证出错:" + ex.Message);
            }
        }
示例#27
0
        public async Task <IActionResult> ConnStrEncrypt([FromQuery] DbConnInfo dbConnInfo)
        {
            CommonResult result       = new CommonResult();
            DBConnResult dBConnResult = new DBConnResult();

            if (dbConnInfo != null)
            {
                if (string.IsNullOrEmpty(dbConnInfo.DbName))
                {
                    result.ErrMsg = "数据库名称不能为空";
                }
                else if (string.IsNullOrEmpty(dbConnInfo.DbAddress))
                {
                    result.ErrMsg = "访问地址不能为空";
                }
                else if (string.IsNullOrEmpty(dbConnInfo.DbUserName))
                {
                    result.ErrMsg = "访问用户不能为空";
                }
                else if (string.IsNullOrEmpty(dbConnInfo.DbPassword))
                {
                    result.ErrMsg = "访问密码不能为空";
                }
                if (dbConnInfo.DbType == "SqlServer")
                {
                    dBConnResult.ConnStr        = string.Format("Server={0};Database={1};User id={2}; password={3};MultipleActiveResultSets=True;", dbConnInfo.DbAddress, dbConnInfo.DbName, dbConnInfo.DbUserName, dbConnInfo.DbPassword);
                    dBConnResult.EncryptConnStr = DEncrypt.Encrypt(dBConnResult.ConnStr);
                    result.Success = true;
                    result.ErrCode = ErrCode.successCode;
                }
                else if (dbConnInfo.DbType == "MySql")
                {
                    dBConnResult.ConnStr        = string.Format("server={0};database={1};uid={2}; pwd={3};", dbConnInfo.DbAddress, dbConnInfo.DbName, dbConnInfo.DbUserName, dbConnInfo.DbPassword);
                    dBConnResult.EncryptConnStr = DEncrypt.Encrypt(dBConnResult.ConnStr);
                    result.Success = true;
                    result.ErrCode = ErrCode.successCode;
                }
                result.ResData = dBConnResult;
            }
            return(ToJsonContent(result));
        }
示例#28
0
 protected void btnSave_ServerClick(object sender, EventArgs e)
 {
     try
     {
         if (Page.IsValid == false)
         {
             return;
         }
         string id  = Session["LoginID"].ToString();
         string pwd = DEncrypt.Encrypt(txtPassword1.Text.Trim());
         new TSUSERBLL().Update(c => c.CN_ID == id, t => new TSUSERInfo {
             CN_PASSWORD = pwd
         });
         MessageBox.Show(this, "保存成功");
     }
     catch (Exception ex)
     {
         LogHelper.WriteErrorLog(ex);
         MessageBox.Show(this, "修改密码出错:" + ex.Message);
     }
 }
示例#29
0
 protected void btnSave_ServerClick(object sender, EventArgs e)
 {
     if (Page.IsValid == false)
     {
         return;
     }
     try
     {
         string userId  = Request.QueryString["UserID"];
         string loginId = Session["LoginID"].ToString();
         if (userId != null)
         {
             var user = bllTSUSER.GetModelByID(userId);
             user.CN_PASSWORD       = DEncrypt.Encrypt(txtPassword.Text);
             user.CN_EMPLOYEE_NO    = txtEmployeeNo.Text;
             user.CN_REALLY_NAME    = txtReallyName.Text;
             user.CN_MODIFY_DATE    = DateTime.Now;
             user.CR_MODIFY_USER_ID = loginId;
             bllTSUSER.Update(user);
         }
         else
         {
             TSUSERInfo user = new TSUSERInfo();
             user.CN_ID             = Guid.NewGuid().ToString();
             user.CN_LOGIN_NAME     = txtLoginName.Text;
             user.CN_PASSWORD       = DEncrypt.Encrypt(txtPassword.Text);
             user.CN_EMPLOYEE_NO    = txtEmployeeNo.Text;
             user.CN_REALLY_NAME    = txtReallyName.Text;
             user.CN_CREATE_DATE    = DateTime.Now;
             user.CR_CREATE_USER_ID = loginId;
             bllTSUSER.Add(user);
         }
         Response.Redirect("/Manager/UserList.aspx");
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, "保存出错" + ex.Message);
     }
 }
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        string loginName;
        string passWord;
        string companyname;    //单位名称
        string country;        //国家
        int    province = 0;   //省

        int city = 0;          //市

        int xian = 0;          //县

        int    sid;            //机构类别
        int    serviesgig = 0; //服务大类
        string serviesmall;    //服务小类
        int    scale   = 0;    //企业规模
        int    capital = 0;    //注册资金
        string createdate;     //企业创建时间
        string count;          // 营业额

        string directions;     //主营业务说明
        string website;        //网址
        string linkman;        //联系人

        string linktel;        //联系电话
        string fex;            //传真号码
        string email;          //电子邮件


        loginName   = this.usrname.Value;
        passWord    = Request.Form["repwd"];
        companyname = Request.Form["company"];
        country     = this.ZoneSelectControl1.CountryID.ToString();

        if (this.ZoneSelectControl1.CityID.ToString() != "")
        {
            city = int.Parse(this.ZoneSelectControl1.CityID.ToString());
        }

        if (this.ZoneSelectControl1.CountyID.ToString() != "")
        {
            xian = int.Parse(this.ZoneSelectControl1.CountyID.ToString());
        }
        if (this.ZoneSelectControl1.ProvinceID.ToString() != "")
        {
            province = int.Parse(this.ZoneSelectControl1.ProvinceID.ToString());
        }
        sid = Convert.ToInt32(structid.SelectedItem.Value);
        if (ServiesControl.ServicesBID.ToString() != "")
        {
            string[] Test      = ServiesControl.ServicesBID.Split(',');
            string   TestValue = Test[0].Trim();
            serviesgig = Convert.ToInt32(TestValue);
        }
        if (Request.Form["scale"].ToString() != "")
        {
            scale = int.Parse(Request.Form["scale"].ToString());
        }
        serviesmall = ServiesControl.ServicesMID.ToString();
        if (Request.Form["capital"].ToString() != "")
        {
            capital = int.Parse(Request.Form["capital"].ToString());
        }

        createdate = Request.Form["createdate"];
        count      = Request.Form["count"];
        directions = Request.Form["directions"];
        website    = Request.Form["website"];
        linkman    = Request.Form["linkman"];
        linktel    = Request.Form["linktel"];
        fex        = Request.Form["fex"];
        email      = Request.Form["email"];



        #region 验证提交的验证码并清空验证码
        ///--------------------------------------------------
        ///--验证提交的验证码并清空验证码
        ///--------------------------------------------------
        string vercode   = Request.Form["vercode"];
        string strRndNum = "";
        //SESSION丢失
        if (Session["valationNo"] == null)
        {
            Response.Write("<script>alert('操作超时!请刷新页面!');</script>");
            return;
        }
        else
        {
            if (vercode.Trim() == "")
            {
                Response.Write("<script>alert('验证码不能为空,请重新提交!');</script>");
                return;
            }
            else
            {
                strRndNum = Session["valationNo"].ToString();
                if (vercode.Trim() != "" && vercode.ToLower().Trim() == strRndNum.ToLower())
                {
                    Session["valationNo"] = "";
                }
                else
                {
                    Response.Write("<script>alert('验证码错误,请重新提交!');</script>");
                    return;
                }
            }
        }
        #endregion


        //注册信息
        SHA1   sha1      = SHA1.Create();
        byte[] passWord2 = sha1.ComputeHash(Encoding.Unicode.GetBytes(passWord.Trim()));

        LoginInfoModel model = new LoginInfoModel();

        if (Request.Cookies["adv_cpa"] != null)
        {
            HttpCookie logCook = Request.Cookies["adv_cpa"];
            model.adsiteID = logCook.Value.ToString();

            model.autoReg = 2;
        }

        model.LoginName     = loginName;
        model.Password      = passWord2;
        model.RoleName      = "0";//会员
        model.ManageTypeID  = "2007";
        model.MemberGradeID = "1001";
        model.IsCheckUp     = false;
        model.Email         = email;
        model.Tel           = linktel;
        model.CompanyName   = companyname;
        model.NickName      = " ";
        model.PWDAnswere    = "";
        model.PWDQuestion   = "";
        model.RequirInfo    = "";

        //--------会员信息
        MemberInfoModel memberModel = new MemberInfoModel();
        memberModel.LoginName    = loginName;
        memberModel.Email        = email;
        memberModel.ManageTypeID = "2007";
        //memberModel.RequirInfo = requirInfo;
        memberModel.Tel      = linktel;
        memberModel.Mobile   = linktel;
        memberModel.Birthday = DateTime.Now;

        // -------------专业服务机构
        Tz888.Model.Register.SS_Agency_Services service = new SS_Agency_Services();
        service.LoginName        = loginName;
        service.OrganName        = companyname;
        service.OrganType        = sid;
        service.CountryCode      = country;
        service.ProvinceID       = province;
        service.CityID           = city;
        service.Area             = xian;
        service.ServiceBigtype   = serviesgig;
        service.ServiceSmalltype = serviesmall;
        service.BusinessCount    = scale;
        service.BusinessView     = directions;
        service.Bankroll         = capital;
        service.FoundDate        = createdate;
        service.Turnover         = count;
        service.www      = website;
        service.LinkName = linkman;
        service.Tel      = linktel;
        service.FAX      = fex;
        service.Email    = email;
        service.Regdate  = DateTime.Now;



        LoginInfoBLL loginfo = new LoginInfoBLL();
        Tz888.BLL.Register.SS_Agency_ServicesBLL smode = new SS_Agency_ServicesBLL();
        MemberInfoBLL member = new MemberInfoBLL();
        try
        {
            //机构服务表

            try
            { smode.AgencyAdd(service); }
            catch (System.Data.SqlClient.SqlException ex)
            {
                throw (new Exception(ex.Message));
            }
            //向注册表写数据


            try
            { loginfo.LogInfoAdd(model); }
            catch (System.Data.SqlClient.SqlException ex)
            {
                throw (new Exception(ex.Message));
            }


            // 会员信息
            int i = member.MemberMessage_Insert(memberModel);

            string encryEmail   = Server.UrlEncode(DEncrypt.Encrypt(email));
            string encryLogname = Server.UrlEncode(DEncrypt.Encrypt(loginName));
            string act          = Server.UrlEncode(DEncrypt.Encrypt("register"));
            string strPass      = Server.UrlEncode(DEncrypt.Encrypt(passWord));
            string ValidUrl     = "ValidSuccessGov.aspx?email=" + encryEmail + "&logname=" + encryLogname + "&act=" + act + "&PassWord="******"数据提交时出错,注册失败。");
        }
        finally
        {
            string encryEmail   = Server.UrlEncode(DEncrypt.Encrypt(email));
            string encryLogname = Server.UrlEncode(DEncrypt.Encrypt(loginName));
            string act          = Server.UrlEncode(DEncrypt.Encrypt("register"));
            string strPass      = Server.UrlEncode(DEncrypt.Encrypt(passWord));
            string ValidUrl     = "ValidSuccessGov.aspx?email=" + encryEmail + "&logname=" + encryLogname + "&act=" + act + "&PassWord=" + strPass;
            Response.Redirect(ValidUrl, true);
        }
    }