예제 #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string oldPwd = MD5Encrypt.GetPass(txtOldPwd.Text.Trim(), currentUser.Encrypt);

            if (oldPwd == currentUser.Pwd)
            {
                string encrypt = RandomHelper.CreateRandomStr(6);
                string newPwd  = MD5Encrypt.GetPass(txtNewPwdT.Text.Trim(), encrypt);
                int    result  = new UserBLL().ModifyPwd(currentUser.Id, newPwd, encrypt);
                txtOldPwd.Text  = String.Empty;
                txtNewPwd.Text  = String.Empty;
                txtNewPwdT.Text = String.Empty;
                if (result > 0)
                {
                    cookie.ClearCookie();
                    Alert.ShowInParent("修改密码成功,请重新登录", String.Empty, "top.location.href='/default.aspx'");
                }
                else
                {
                    Alert.ShowInTop("修改密码失败");
                }
            }
            else
            {
                Alert.ShowInTop("输入的旧密码错误");
            }
        }
예제 #2
0
파일: UserBiz.cs 프로젝트: kiss5523/PMSAPI
        private SingleApiResponse EditUser(UserInfoSaveRequest req)
        {
            var user = RepoBase.Instance.GetWhere <SS_USER>(x => x.U_ID == req.U_ID).FirstOrDefault();

            if (user == null)
            {
                return new SingleApiResponse()
                       {
                           BizErrorMsg = "无此用户", ErrCode = 1001
                       }
            }
            ;
            user.U_NAME = req.U_NAME;

            if (!string.IsNullOrEmpty(req.U_PWD))
            {
                string encrypt = RandomHelper.CreateRandomStr(6);

                user.U_ENCRYPT = encrypt;
                user.U_PWD     = MD5Encrypt.GetPass(req.U_PWD, encrypt);
            }

            user.U_REALNAME   = req.U_REALNAME;
            user.U_EMAIL      = req.U_EMAIL;
            user.U_MOBILE     = req.U_MOBILE;
            user.U_TEL        = req.U_TEL;
            user.U_DISABLED   = req.U_DISABLED;
            user.U_PHOTO      = req.U_PHOTO;
            user.U_UPDATETIME = DateTime.Now;

            RepoBase.Instance.Update(user);
            SetRoles(req.U_ID.Value, req.U_RoleIds);
            return(new SingleApiResponse());
        }
예제 #3
0
        private void LoadLogin()
        {
            string userName = HttpUtility.HtmlEncode(RequestHelper.GetRequestString("username"));
            string password = HttpUtility.HtmlEncode(RequestHelper.GetRequestString("userpwd"));

            //请填写完整
            if (userName.Length == 0 || password.Length == 0)
            {
                Response.Write(ShowMassage.Html("请填写完整", "default.aspx"));
            }
            else
            {
                UserModel model = bll.GetModelByUserName(userName);
                if (model == null)
                {
                    logBLL.AddLog("登录", Request.RawUrl, Request.HttpMethod, "登录系统;结果:失败(用户名不存在)", 0, userName);
                    Response.Write(ShowMassage.Html("用户名不存在", "default.aspx"));
                }
                else
                {
                    if (model.Pwd == MD5Encrypt.GetPass(password, model.Encrypt))
                    {
                        if (model.Disabled == false)
                        {
                            bll.UpdateByLogin(model.Id, RequestHelper.GetIP());
                            //登录成功,保存至cookie
                            RABCCookie cookie = new RABCCookie();
                            DateTime   time   = DateTime.Now;
                            cookie.AddUserNameCookie(model.Name, time, 0);
                            cookie.AddPurviewCodeCookie(bll.GetPurviewCodesByUserId(model.Id), time, 0);
                            logBLL.AddLog("登录", Request.RawUrl, Request.HttpMethod, "登录系统;结果:成功", model.Id, model.Name);
                            //跳转至首页
                            Response.Write(ShowMassage.Html("登录成功", "index.aspx"));
                        }
                        else
                        {
                            logBLL.AddLog("登录", Request.RawUrl, Request.HttpMethod, "登录系统;结果:失败(该用户状态为禁止登录)", model.Id, model.Name);
                            Response.Write(ShowMassage.Html("该用户已经被禁止登录", "default.aspx"));
                        }
                    }
                    else
                    {
                        logBLL.AddLog("登录", Request.RawUrl, Request.HttpMethod, "登录系统;结果:失败(密码错误)", model.Id, model.Name);
                        Response.Write(ShowMassage.Html("密码错误", "default.aspx"));
                    }
                }
            }
            Response.End();
        }
예제 #4
0
        /// <summary>
        /// 锁屏
        /// </summary>
        /// <returns></returns>
        public async Task <IActionResult> LockScreen(string userpwd)
        {
            UserEntity currentUser = await workContext.GetCurrentUser();

            if (userpwd.IsNotNullOrEmpty())
            {
                string pwd1 = MD5Encrypt.GetPass(userpwd, currentUser.U_ENCRYPT);
                if (pwd1 == currentUser.U_PWD)
                {
                    await userService.SetLockScreenAsync(currentUser.U_ID, false);

                    return(RedirectToAction("Index", "Home"));
                }
                ViewData["msg"] = "密码错误,请重新输入";
            }
            else
            {
                await userService.SetLockScreenAsync(currentUser.U_ID, true);
            }
            return(View(currentUser));
        }
예제 #5
0
파일: UserBiz.cs 프로젝트: kiss5523/PMSAPI
        private SingleApiResponse AddUser(UserInfoSaveRequest req)
        {
            var user = RepoBase.Instance.GetWhere <SS_USER>(x => x.U_NAME == req.U_NAME).FirstOrDefault();

            if (user != null)
            {
                return new SingleApiResponse()
                       {
                           BizErrorMsg = "此用户已存在", ErrCode = 1002
                       }
            }
            ;
            string encrypt = RandomHelper.CreateRandomStr(6);

            user = new SS_USER()
            {
                U_NAME                   = req.U_NAME,
                U_ENCRYPT                = encrypt,
                U_PWD                    = MD5Encrypt.GetPass(req.U_PWD, encrypt),
                U_REALNAME               = req.U_REALNAME,
                U_EMAIL                  = req.U_EMAIL,
                U_MOBILE                 = req.U_MOBILE,
                U_TEL                    = req.U_TEL,
                U_PHOTO                  = req.U_PHOTO,
                U_CREATETIME             = DateTime.Now,
                U_UPDATETIME             = DateTime.Now,
                U_LASTLOGINTIME          = DateTime.Now,
                U_PREVLOGINTIME          = DateTime.Now,
                U_LASTMODIFYPASSWORDTIME = DateTime.Now
            };

            var id = RepoBase.Instance.Add(user);

            SetRoles(Convert.ToInt32(id), req.U_RoleIds);
            return(new SingleApiResponse());
        }
예제 #6
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            //保存权限
            if (!VerifyPurview(",SU-EDIT,"))
            {
                Alert.ShowInParent(CHECK_POWER_FAIL_ACTION_MESSAGE);
                return;
            }
            string strErr = String.Empty;
            int    num    = 1;

            if (id <= 0)
            {
                strErr += num + "、参数错误 <br />";
                num++;
            }
            string vName = HttpUtility.HtmlEncode(txtVerityName.Text.Trim());

            if (vName.Length == 0)
            {
                strErr += num + "、真实姓名不能为空 <br />";
            }
            if (strErr.Length > 0)
            {
                Alert.ShowInParent(strErr);
                return;
            }
            UserModel model = new UserModel();

            model.Id = id;
            string pwd = HttpUtility.HtmlEncode(txtPwd.Text.Trim());

            if (pwd.Length > 0)
            {
                model.Encrypt = RandomHelper.CreateRandomStr(6);
                model.Pwd     = MD5Encrypt.GetPass(pwd, model.Encrypt);
            }
            model.RealName = vName;
            model.Email    = HttpUtility.HtmlEncode(txtEmail.Text.Trim());
            model.Mobile   = HttpUtility.HtmlEncode(txtMobile.Text.Trim());
            model.Tel      = HttpUtility.HtmlEncode(txtTel.Text.Trim());
            model.Disabled = chkDisabled.Checked;
            int     result = 0;
            UserBLL bll    = new UserBLL();

            using (DataTable roleDT = new DataTable())
            {
                roleDT.Columns.Add("roleid", typeof(int));
                roleDT.Columns.Add("userid", typeof(int));
                #region 角色用户
                string userRole = hfSelectedRole.Text.Trim();
                if (userRole.Length > 0)
                {
                    string[] userRoleArr = userRole.Split(',');
                    foreach (string s in userRoleArr)
                    {
                        DataRow dr = roleDT.NewRow();
                        dr[0] = Convert.ToInt32(s);
                        dr[1] = model.Id;
                        roleDT.Rows.Add(dr);
                    }
                }
                #endregion
                result = bll.Modify(model, roleDT);
            }
            if (result > 0)
            {
                Alert.ShowInParent("保存成功!", String.Empty, ActiveWindow.GetHidePostBackReference());
            }
            else
            {
                Alert.ShowInParent("保存失败");
            }
        }
예제 #7
0
 public Messages Save(UserParam model)
 {
     if (model != null && model.U_NAME.IsNotNullOrEmpty() && model.U_REALNAME.IsNotNullOrEmpty())
     {
         UserEntity user = new UserEntity();
         user.U_ID   = model.U_ID;
         user.U_NAME = model.U_NAME;
         if (model.U_PWD.IsNotNullOrEmpty())
         {
             string encrypt = RandomHelper.CreateRandomStr(6);
             user.U_ENCRYPT = encrypt;
             user.U_PWD     = MD5Encrypt.GetPass(model.U_PWD, encrypt);
         }
         user.U_REALNAME = model.U_REALNAME;
         user.U_EMAIL    = model.U_EMAIL ?? "";
         user.U_MOBILE   = model.U_MOBILE ?? "";
         user.U_TEL      = model.U_TEL ?? "";
         user.U_PHOTO    = model.U_PHOTO ?? "";
         using (DataTable roleDT = new DataTable())
         {
             roleDT.Columns.Add("roleid", typeof(int));
             roleDT.Columns.Add("userid", typeof(int));
             if (model.RoleIds.IsNotNullOrEmpty())
             {
                 string[] userRoleArr = model.RoleIds.TrimEnd(',').Split(',');
                 if (userRoleArr != null && userRoleArr.Length > 0)
                 {
                     foreach (string s in userRoleArr)
                     {
                         DataRow dr = roleDT.NewRow();
                         dr[0] = Convert.ToInt32(s);
                         dr[1] = model.U_ID;
                         roleDT.Rows.Add(dr);
                     }
                 }
             }
             int result = 0;
             if (model.U_ID > 0)
             {
                 result = userRepository.Modify(user, roleDT);
             }
             else
             {
                 result = userRepository.Add(user, roleDT);
             }
             if (result > 0)
             {
                 messages.Msg     = "保存成功";
                 messages.Success = true;
             }
             else if (result == -10000)
             {
                 messages.Msg = "存在相同用户名的数据";
             }
             else
             {
                 messages.Msg = "保存失败";
             }
         }
     }
     return(messages);
 }