Beispiel #1
0
        public async Task ModifyPasswordAsync(Int32 userId, String newPassword, Boolean isTogetherSetLockPassword)
        {
            Check.IfNullOrZero(newPassword);

            var password = PasswordUtil.CreateDbPassword(newPassword);
            await _userContext.ModifyPasswordAsync(userId, password, isTogetherSetLockPassword);
        }
Beispiel #2
0
        protected void btnSave_OnClick(object sender, EventArgs e)
        {
            // 检查当前密码是否正确
            string oldPass        = tbxOldPassword.Text.Trim();
            string newPass        = tbxNewPassword.Text.Trim();
            string confirmNewPass = tbxConfirmNewPassword.Text.Trim();

            if (newPass != confirmNewPass)
            {
                tbxConfirmNewPassword.MarkInvalid("确认密码和新密码不一致!");
                return;
            }

            IList <ICriterion> qryList = new List <ICriterion>();

            qryList.Add(Expression.Eq("Name", User.Identity.Name));
            users user = Core.Container.Instance.Resolve <IServiceUsers>().GetEntityByFields(qryList);

            //User user = DB.Users.Where(u => u.Name == User.Identity.Name).FirstOrDefault();

            if (user != null)
            {
                if (!PasswordUtil.ComparePasswords(user.Password, oldPass))
                {
                    tbxOldPassword.MarkInvalid("当前密码不正确!");
                    return;
                }

                user.Password = PasswordUtil.CreateDbPassword(newPass);
                Core.Container.Instance.Resolve <IServiceUsers>().Update(user);
                //DB.SaveChanges();

                Alert.ShowInTop("修改密码成功!");
            }
        }
Beispiel #3
0
        protected void btn_save_Click(object sender, EventArgs e)
        {
            if (passwordIsOk(txb_origPsw.Text))
            {
                if (txb_password.Text == txb_password_confirm.Text)
                {
                    string pswMd5 = PasswordUtil.CreateDbPassword(txb_password.Text.Trim());
                    string sqlCmd = "update OA_Sys_EmployeeInfo set password='******' where id=" + GetUser();
                    SqlSel.ExeSql(sqlCmd);

                    SimpleForm1.Reset();

                    Alert.Show("密码修改完成!");
                }
                else
                {
                    Alert.ShowInTop("两次输入的密码不一致!请重新输入。");
                    return;
                }
            }
            else
            {
                Alert.ShowInTop("原密码不匹配!");
                return;
            }
        }
Beispiel #4
0
        public IActionResult UpdatePassword([FromBody] UserCenterUpdatePasswordDto parm)
        {
            if (Convert.ToBoolean(AppSettings.Configuration["AppSettings:Demo"]))
            {
                ToResponse(StatusCodeType.Error, "当前为演示模式 , 您无权修改任何数据");
            }

            var userSession = _tokenManager.GetSessionInfo();

            var userInfo = _usersService.GetId(userSession.UserID);

            // 验证旧密码是否正确
            if (!PasswordUtil.ComparePasswords(userInfo.UserID, userInfo.Password, parm.CurrentPassword.Trim()))
            {
                return(ToResponse(StatusCodeType.Error, "旧密码输入不正确"));
            }

            // 更新用户密码
            var response = _usersService.Update(m => m.UserID == userInfo.UserID, m => new Sys_Users()
            {
                Password = PasswordUtil.CreateDbPassword(userInfo.UserID, parm.ConfirmPassword.Trim())
            });

            // 删除登录会话记录
            _tokenManager.RemoveAllSession(userInfo.UserID);

            return(ToResponse(response));
        }
Beispiel #5
0
        protected void btnSave_OnClick(object sender, EventArgs e)
        {
            // 检查当前密码是否正确
            string oldPass        = tbxOldPassword.Text.Trim();
            string newPass        = tbxNewPassword.Text.Trim();
            string confirmNewPass = tbxConfirmNewPassword.Text.Trim();

            if (newPass != confirmNewPass)
            {
                tbxConfirmNewPassword.MarkInvalid("确认密码和新密码不一致!");
                return;
            }

            User user = DB.Users.Where(u => u.Name == User.Identity.Name).FirstOrDefault();

            if (user != null)
            {
                if (!PasswordUtil.ComparePasswords(user.Password, oldPass))
                {
                    tbxOldPassword.MarkInvalid("当前密码不正确!");
                    return;
                }

                user.Password = PasswordUtil.CreateDbPassword(newPass);
                DB.SaveChanges();

                Alert.ShowInTop("修改密码成功!");
            }
        }
Beispiel #6
0
        public async Task <IActionResult> OnPostChangePassword_btnSave_OnClickAsync(string tbxOldPassword, string tbxNewPassword, string tbxConfirmNewPassword)
        {
            int?id = GetIdentityID();

            // 检查当前密码是否正确
            string oldPass        = tbxOldPassword.Trim();
            string newPass        = tbxNewPassword.Trim();
            string confirmNewPass = tbxConfirmNewPassword.Trim();

            if (newPass != confirmNewPass)
            {
                UIHelper.TextBox("tbxConfirmNewPassword").MarkInvalid("确认密码和新密码不一致!");
            }
            else
            {
                User user = await DB.Users.Where(u => u.ID == id).AsNoTracking().FirstOrDefaultAsync();

                if (user != null)
                {
                    if (!PasswordUtil.ComparePasswords(user.Password, oldPass))
                    {
                        UIHelper.TextBox("tbxOldPassword").MarkInvalid("当前密码不正确!");
                    }
                    else
                    {
                        user.Password = PasswordUtil.CreateDbPassword(newPass);
                        await DB.SaveChangesAsync();

                        Alert.ShowInTop("修改密码成功!");
                    }
                }
            }

            return(UIHelper.Result());
        }
Beispiel #7
0
        public IActionResult Register([FromBody] UsersRegisterDto parm)
        {
            var captchaCode = RedisServer.Cache.Get($"Captcha:{parm.Uuid}");

            RedisServer.Cache.Del($"Captcha:{parm.Uuid}");

            if (parm.Code.ToUpper() != captchaCode)
            {
                return(ToResponse(StatusCodeType.Error, "输入验证码无效"));
            }
            //判断用户名是否存在
            if (_usersService.Any(m => m.UserName == parm.UserName))
            {
                return(ToResponse(StatusCodeType.Error, $"添加 {parm.UserID} 失败,该用户名已存在,不能重复!"));
            }
            //判断手机号是否存在
            if (_usersService.Any(m => m.Phone == parm.Phone))
            {
                return(ToResponse(StatusCodeType.Error, $"添加 {parm.UserID} 失败,该手机号已存在,不能重复!"));
            }
            parm.UserID = Guid.NewGuid().ToString();
            //从Dto映射到实体
            var userInfo = parm.Adapt <Sys_Users>();

            userInfo.Password = PasswordUtil.CreateDbPassword(userInfo.UserID, userInfo.Password.Trim());

            return(ToResponse(_usersService.Add(userInfo)));
        }
Beispiel #8
0
        public async Task ModifyLockScreenPasswordAsync(Int32 userId, String newScreenPassword)
        {
            Check.IfNullOrZero(newScreenPassword);

            var newPassword = PasswordUtil.CreateDbPassword(newScreenPassword);
            await _userContext.ModifyLockScreenPasswordAsync(userId, newPassword);

            await CacheHelper.RemoveKeyWhenModify(new ConfigCacheKey(userId));
        }
Beispiel #9
0
        public async Task AddNewUserAsync(UserDto userDto)
        {
            Check.IfNullOrZero(userDto);

            var user        = userDto.ConvertToModel <UserDto, User>();
            var newPassword = PasswordUtil.CreateDbPassword(user.LoginPassword);

            var internalNewUser = new User(user.Name, newPassword, user.Roles, user.IsAdmin ? UserType.Admin : UserType.User);
            await _userContext.AddNewUserAsync(internalNewUser);
        }
        protected void btnSaveClose_Click(object sender, EventArgs e)
        {
            int   id   = GetQueryIntValue("id");
            users item = Core.Container.Instance.Resolve <IServiceUsers>().GetEntity(id);

            item.Password = PasswordUtil.CreateDbPassword(tbxPassword.Text.Trim());
            Core.Container.Instance.Resolve <IServiceUsers>().Update(item);

            //Alert.Show("保存成功!", String.Empty, Alert.DefaultIcon, ActiveWindow.GetHidePostBackReference());
            PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
        }
Beispiel #11
0
        protected void btnSaveClose_Click(object sender, EventArgs e)
        {
            int id = GetQueryIntValue("id");

            Infobasis.Data.DataEntity.User item = DB.Users.Find(id);
            item.Password = PasswordUtil.CreateDbPassword(tbxPassword.Text.Trim());
            DB.SaveChanges();

            //Alert.Show("保存成功!", String.Empty, Alert.DefaultIcon, ActiveWindow.GetHidePostBackReference());
            PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
        }
        public async Task <IActionResult> OnPostUserChangePassword_btnSaveClose_ClickAsync(int hfUserID, string tbxPassword)
        {
            var item = await DB.Users.FindAsync(hfUserID);

            item.Password = PasswordUtil.CreateDbPassword(tbxPassword.Trim());
            await DB.SaveChangesAsync();

            // 关闭本窗体(触发窗体的关闭事件)
            ActiveWindow.HidePostBack();

            return(UIHelper.Result());
        }
Beispiel #13
0
        public IActionResult ResetPassword([FromBody] UsersResetPasswordDto parm)
        {
            // 更新用户密码
            var response = _usersService.Update(m => m.UserID == parm.UserID, m => new Sys_Users()
            {
                Password = PasswordUtil.CreateDbPassword(parm.UserID, parm.ConfirmPassword.Trim())
            });

            // 删除登录会话记录
            _tokenManager.RemoveAllSession(parm.UserID);

            return(toResponse(response));
        }
Beispiel #14
0
        public IActionResult Create([FromBody] UsersCreateDto parm)
        {
            //判断用户是否已经存在
            if (_usersService.Any(m => m.UserID == parm.UserID))
            {
                return(toResponse(StatusCodeType.Error, $"添加 {parm.UserID} 失败,该用户已存在,不能重复!"));
            }

            //从 Dto 映射到 实体
            var userInfo = parm.Adapt <Sys_Users>().ToCreate(_tokenManager.GetSessionInfo());

            userInfo.Password = PasswordUtil.CreateDbPassword(userInfo.UserID, userInfo.Password.Trim());

            return(toResponse(_usersService.Add(userInfo)));
        }
Beispiel #15
0
        private void SaveItem()
        {
            Infobasis.Data.DataEntity.Company item = new Infobasis.Data.DataEntity.Company();
            item.Name        = tbxName.Text.Trim();
            item.CompanyCode = tbxCompanyCode.Text.Trim();
            item.Notes       = tbxRemark.Text;
            if (tbxExpiredDatetime.SelectedDate.HasValue)
            {
                item.ExpiredDatetime = tbxExpiredDatetime.SelectedDate.Value;
            }
            item.MaxUsers           = Infobasis.Web.Util.Change.ToInt(tbxMaxUsers.Text);
            item.ClientAdminAccount = tbxClientAdminAccount.Text;
            item.CompanyStatus      = CompanyStatus.Enabled;
            item.CreateDatetime     = DateTime.Now;
            item.CreateByID         = UserInfo.Current.ID;
            item.CreateByName       = UserInfo.Current.ChineseName;

            string clientAdminPwd = tbxClientAdminAccountPwd.Text.Trim();

            // 添加管理员
            item.Users = new List <Infobasis.Data.DataEntity.User>();
            item.Users.Add(new Infobasis.Data.DataEntity.User()
            {
                CompanyID       = item.ID,
                Name            = item.ClientAdminAccount,
                ChineseName     = "系统管理员",
                IsClientAdmin   = true,
                Password        = PasswordUtil.CreateDbPassword(clientAdminPwd),
                DefaultPageSize = 20,
                Enabled         = true,
                CreateByID      = UserInfo.Current.ID,
                CreateByName    = UserInfo.Current.ChineseName,
                CreateDatetime  = DateTime.Now
            });

            DB.Companys.Add(item);
            DB.SaveChanges();

            int companyID           = item.ID;
            IInfobasisDataSource db = InfobasisDataSource.Create();
            int userID = item.Users.FirstOrDefault().ID;

            //需要手动更新,因为CompanyID被直接赋为当前登录人
            db.ExecuteNonQuery("UPDATE SYtbUser SET CompanyID = @CompanyID WHERE ID = @UserID", companyID, userID);
            db.ExecuteNonQuery("EXEC usp_SY_CreateNewComanyDefaultData @CompanyID, @UserID", companyID, userID);

            PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
        }
Beispiel #16
0
        protected void btn_save_Click(object sender, EventArgs e)
        {
            string sqlCmd     = "";
            int    userStatus = ckeckBox_enabled.Checked ? 1 : 0;

            if (string.IsNullOrEmpty(recvId))
            {
                sqlCmd  = "insert into OA_Sys_EmployeeInfo (loginId,password,chineseName,deptId,dutyId,useStatus,phoneNumber) values (";
                sqlCmd += "'" + txb_loginID.Text + "','" + PasswordUtil.CreateDbPassword("123456") + "','" + txb_chineseName.Text + "',";
                sqlCmd += "'" + ddl_depart.SelectedValue + "','" + ddl_duty.SelectedValue + "','" + userStatus + "','" + numbb_phoneNumb.Text + "')";
                int exeCount = SqlSel.ExeSql(sqlCmd);
                if (exeCount == 1)
                {
                    sqlCmd = "select max(id) from OA_Sys_EmployeeInfo";
                    string newUserId = SqlSel.GetSqlScale(sqlCmd).ToString();

                    //更新角色信息
                    string[] selectValueArray = ckb_roleList.SelectedValueArray;
                    foreach (string item in selectValueArray)
                    {
                        sqlCmd  = "insert into OA_Sys_UserRole (userid,roleid,addtime) values (";
                        sqlCmd += "'" + newUserId + "','" + item + "','" + DateTime.Now + "')";
                        SqlSel.ExeSql(sqlCmd);
                    }
                }
            }
            else
            {
                sqlCmd  = "update OA_Sys_EmployeeInfo set loginId='" + txb_loginID.Text + "',chineseName='" + txb_chineseName.Text + "',deptId='" + ddl_depart.SelectedValue + "',";
                sqlCmd += "dutyId='" + ddl_duty.SelectedValue + "',useStatus='" + userStatus + "',phoneNumber='" + numbb_phoneNumb.Text + "' where id=" + recvId;
                SqlSel.ExeSql(sqlCmd);

                //删除用户现有角色
                sqlCmd += "delete from OA_Sys_UserRole where userid=" + recvId;
                SqlSel.ExeSql(sqlCmd);

                string[] selectValueArray = ckb_roleList.SelectedValueArray;
                foreach (string item in selectValueArray)
                {
                    sqlCmd  = "insert into OA_Sys_UserRole (userid,roleid,addtime) values (";
                    sqlCmd += "'" + recvId + "','" + item + "','" + DateTime.Now + "')";
                    SqlSel.ExeSql(sqlCmd);
                }
            }

            Alert.ShowInTop("保存成功!");
            PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
        }
Beispiel #17
0
        public ActionResult btnEdit_Click([Bind(Include = "ID,FCompanyNumber,UserName,UserPwd,UserSex,UserBirthday,UserMail,UserEnabledisable,UserRemark,UserPumpGroup,FCustomerID,UserType,IsOther")] Panda_Customer cus)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (Panda_UserInfoDal.Exist(" and UserName='******' and UserName<>'" + Request["tbxOldName"] + "'").Rows.Count == 0)
                    {
                        Hashtable hasData = new Hashtable();
                        hasData["ID"]             = Request["tbxID"];
                        hasData["FCompanyNumber"] = Request["ddlCompany"];
                        hasData["UserName"]       = Request["tbxName"];
                        if (!Request["tbxPassword"].Equals(Request["tbxoldPwd"]))
                        {
                            hasData["UserPwd"] = PasswordUtil.CreateDbPassword(Request["tbxPassword"]);
                        }
                        hasData["UserSex"]      = Request["ddlSex"];
                        hasData["UserBirthday"] = Request["dpBirthday"];
                        //hasData["UserTel"] = Request["ddlCompany"];
                        hasData["UserMail"]          = Request["tbxEmail"];
                        hasData["UserEnabledisable"] = Request["ddlEnable"];
                        hasData["UserRemark"]        = Request["tbxRemark"];
                        hasData["UserPumpGroup"]     = Request["tbxPumpGroupID"];
                        hasData["FCustomerID"]       = Request["tbxCustomerID"];
                        hasData["UserType"]          = Request["ddlType"];
                        hasData["IsOther"]           = Request["ddlType"] == "4" ? "1" : "0";
                        hasData["FUpdUser"]          = GetIdentityName();
                        hasData["FUpdDate"]          = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ssss"));
                        Panda_UserInfoDal.Update(hasData);
                        ShowNotify("修改成功!");
                        // 关闭本窗体(触发窗体的关闭事件)
                        PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
                    }
                    else
                    {
                        ShowNotify("用户名重复,请更换!");
                    }
                }
            }
            catch
            {
                ShowNotify("修改失败!");
            }

            return(UIHelper.Result());
        }
Beispiel #18
0
        public async Task <IActionResult> OnPostUserNew_btnSaveClose_ClickAsync(string hfSelectedDept, string hfSelectedRole, string hfSelectedTitle)
        {
            if (ModelState.IsValid)
            {
                var _user = await DB.Users.Where(u => u.Name == CurrentUser.Name).FirstOrDefaultAsync();

                if (_user != null)
                {
                    Alert.Show("用户 " + CurrentUser.Name + " 已经存在!");
                    return(UIHelper.Result());
                }

                // 创建保存到数据库的密码
                CurrentUser.Password   = PasswordUtil.CreateDbPassword(CurrentUser.Password.Trim());
                CurrentUser.CreateTime = DateTime.Now;

                // 添加所有部门
                if (!String.IsNullOrEmpty(hfSelectedDept))
                {
                    CurrentUser.DeptID = Convert.ToInt32(hfSelectedDept);
                }

                // 添加所有角色
                if (!String.IsNullOrEmpty(hfSelectedRole))
                {
                    int[] roleIDs = StringUtil.GetIntArrayFromString(hfSelectedRole);
                    AddEntities2 <RoleUser>(roleIDs, CurrentUser.ID);
                }

                // 添加所有职称
                if (!String.IsNullOrEmpty(hfSelectedTitle))
                {
                    int[] titleIDs = StringUtil.GetIntArrayFromString(hfSelectedTitle);
                    AddEntities2 <TitleUser>(titleIDs, CurrentUser.ID);
                }

                DB.Users.Add(CurrentUser);
                await DB.SaveChangesAsync();


                // 关闭本窗体(触发窗体的关闭事件)
                ActiveWindow.HidePostBack();
            }

            return(UIHelper.Result());
        }
Beispiel #19
0
        private void SaveItem()
        {
            users item = new users();

            item.Name           = tbxName.Text.Trim();
            item.Password       = PasswordUtil.CreateDbPassword(tbxPassword.Text.Trim());
            item.ChineseName    = tbxRealName.Text.Trim();
            item.Gender         = ddlGender.SelectedValue;
            item.CompanyEmail   = tbxCompanyEmail.Text.Trim();
            item.Email          = tbxEmail.Text.Trim();
            item.OfficePhone    = tbxOfficePhone.Text.Trim();
            item.OfficePhoneExt = tbxOfficePhoneExt.Text.Trim();
            item.HomePhone      = tbxHomePhone.Text.Trim();
            item.CellPhone      = tbxCellPhone.Text.Trim();
            item.Remark         = tbxRemark.Text.Trim();
            item.Enabled        = cbxEnabled.Checked;
            item.CreateTime     = DateTime.Now;

            // 添加所有部门
            if (!String.IsNullOrEmpty(hfSelectedDept.Text))
            {
                item.DeptID = Convert.ToInt32(hfSelectedDept.Text);
            }

            Core.Container.Instance.Resolve <IServiceUsers>().Create(item);

            item = new users();
            IList <ICriterion> qryList = new List <ICriterion>();

            qryList.Add(Expression.Eq("Name", tbxName.Text.Trim()));
            item = Core.Container.Instance.Resolve <IServiceUsers>().GetEntityByFields(qryList);


            // 添加所有角色
            if (!String.IsNullOrEmpty(hfSelectedRole.Text))
            {
                int[] roleIDs = StringUtil.GetIntArrayFromString(hfSelectedRole.Text);
                foreach (int rolsid in roleIDs)
                {
                    roleusers obj = new roleusers {
                        RoleID = rolsid, UserID = item.ID
                    };
                    Core.Container.Instance.Resolve <IServiceRoleUsers>().Create(obj);
                }
            }
        }
Beispiel #20
0
        private void SaveItem()
        {
            User item = new User();

            item.Name           = tbxName.Text.Trim();
            item.Password       = PasswordUtil.CreateDbPassword(tbxPassword.Text.Trim());
            item.ChineseName    = tbxRealName.Text.Trim();
            item.Gender         = ddlGender.SelectedValue;
            item.CompanyEmail   = tbxCompanyEmail.Text.Trim();
            item.Email          = tbxEmail.Text.Trim();
            item.OfficePhone    = tbxOfficePhone.Text.Trim();
            item.OfficePhoneExt = tbxOfficePhoneExt.Text.Trim();
            item.HomePhone      = tbxHomePhone.Text.Trim();
            item.CellPhone      = tbxCellPhone.Text.Trim();
            item.Remark         = tbxRemark.Text.Trim();
            item.Enabled        = cbxEnabled.Checked;
            item.CreateTime     = DateTime.Now;

            // 添加所有部门
            if (!String.IsNullOrEmpty(hfSelectedDept.Text))
            {
                Dept dept = Attach <Dept>(Convert.ToInt32(hfSelectedDept.Text));
                item.Dept = dept;
            }

            // 添加所有角色
            if (!String.IsNullOrEmpty(hfSelectedRole.Text))
            {
                item.Roles = new List <Role>();
                int[] roleIDs = StringUtil.GetIntArrayFromString(hfSelectedRole.Text);

                AddEntities <Role>(item.Roles, roleIDs);
            }

            // 添加所有职称
            if (!String.IsNullOrEmpty(hfSelectedTitle.Text))
            {
                item.Titles = new List <Title>();
                int[] titleIDs = StringUtil.GetIntArrayFromString(hfSelectedTitle.Text);

                AddEntities <Title>(item.Titles, titleIDs);
            }

            DB.Users.Add(item);
            DB.SaveChanges();
        }
Beispiel #21
0
        public ActionResult btnCreate_Click()
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (Panda_UserInfoDal.Exist(" and UserName='******'").Rows.Count == 0)
                    {
                        Hashtable hasData = new Hashtable();
                        hasData["FCompanyNumber"] = Request["ddlCompany"];
                        hasData["UserName"]       = Request["tbxName"];
                        hasData["UserPwd"]        = PasswordUtil.CreateDbPassword(Request["tbxPassword"]);
                        hasData["UserSex"]        = Request["ddlSex"];
                        hasData["UserBirthday"]   = Request["dpBirthday"];
                        //hasData["UserTel"] = Request["ddlCompany"];
                        hasData["UserMail"]          = Request["tbxEmail"];
                        hasData["UserEnabledisable"] = Request["ddlEnable"];
                        hasData["UserRemark"]        = Request["tbxRemark"];
                        hasData["UserPumpGroup"]     = Request["tbxPumpGroupID"];
                        hasData["FCustomerID"]       = Request["tbxCustomerID"];
                        hasData["UserType"]          = Request["ddlType"];
                        hasData["IsOther"]           = Request["ddlType"] == "4" ? "1" : "0";
                        hasData["FIsDelete"]         = 0;
                        hasData["FCreateUser"]       = GetIdentityName();
                        hasData["FCreateDate"]       = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ssss"));
                        Panda_UserInfoDal.Insert(hasData);

                        ShowNotify("添加成功!");
                        // 关闭本窗体(触发窗体的关闭事件)
                        PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
                    }
                    else
                    {
                        ShowNotify("用户名重复,请更换!");
                    }
                }
                catch
                {
                    ShowNotify("添加失败!");
                }
            }

            return(UIHelper.Result());
        }
        protected void btnSaveClose_Click(object sender, EventArgs e)
        {
            int id = GetQueryIntValue("id");

            string Password = PasswordUtil.CreateDbPassword(tbxPassword.Text.Trim());
            string strWhere = "ID=" + id;

            if (Common.UpdateTable("sys_Users", new string[] { "Password" }, new string[, ] {
                { "" + Password + "", "1" }
            }, strWhere) == 0)
            {
                Alert.Show("修改成功!", String.Empty, ActiveWindow.GetHidePostBackReference());
            }
            else
            {
                Alert.Show("修改失败!", String.Empty, ActiveWindow.GetHidePostBackReference());
            }
            //Alert.Show("保存成功!", String.Empty, Alert.DefaultIcon, ActiveWindow.GetHidePostBackReference());
            //PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
        }
        protected void btn_save_Click(object sender, EventArgs e)
        {
            if (txb_password.Text == txb_password_confirm.Text)
            {
                if (!string.IsNullOrEmpty(recvId))
                {
                    string pswMd5 = PasswordUtil.CreateDbPassword(txb_password.Text.Trim());
                    string sqlCmd = "update OA_Sys_EmployeeInfo set password='******' where id=" + recvId;
                    SqlSel.ExeSql(sqlCmd);

                    Alert.Show("密码修改完成!");
                    PageContext.RegisterStartupScript(ActiveWindow.GetHideReference());
                }
            }
            else
            {
                Alert.ShowInTop("两次输入的密码不一致!请重新输入。");
                return;
            }
        }
        public IActionResult ResetPassword([FromBody] UsersResetPasswordDto parm)
        {
            var userSession = _tokenManager.GetSessionInfo();

            if (_usersService.GetFirst(m => m.ID == parm.ID) == null)
            {
                return(toResponse(StatusCodeType.Error, "当前用户不存在,请核对"));
            }

            // 更新用户密码
            var response = _usersService.Update(m => m.UserID == parm.UserID, m => new Sys_Users()
            {
                Password = PasswordUtil.CreateDbPassword(parm.ID, parm.ConfirmPassword.Trim())
            });

            // 删除登录会话记录
            _tokenManager.RemoveAllSession(parm.UserID);

            return(toResponse(response));
        }
        private static List <User> GetUsers()
        {
            string[] USER_NAMES  = { "男", "童光喜", "男", "方原柏", "女", "祝春亚", "男", "涂辉", "男", "舒兆国", "男", "熊忠文", "男", "徐吉琳", "男", "方金海", "男", "包卫峰", "女", "靖小燕", "男", "杨习斌", "男", "徐长旺", "男", "聂建雄", "男", "周敦友", "男", "陈友庭", "女", "陆静芳", "男", "袁国柱", "女", "骆新桂", "男", "许治国", "男", "马先加", "男", "赵恢川", "男", "柯常胜", "男", "黄国鹏", "男", "柯尊北", "男", "刘海云", "男", "罗清波", "男", "张业权", "女", "丁溯鋆", "男", "吴俊", "男", "郑江", "男", "李亚华", "男", "石光富", "男", "谭志洪", "男", "胡中生", "男", "董龙剑", "男", "陈红", "男", "汪海平", "男", "彭道洲", "女", "尹莉君", "男", "占耀玲", "男", "付杰", "男", "王红艳", "男", "邝兴", "男", "饶玮", "男", "王方胜", "男", "陈劲松", "男", "邓庆华", "男", "王石林", "男", "胡俊明", "男", "索相龙", "男", "陈海军", "男", "吴文涛", "女", "熊望梅", "女", "段丽华", "女", "胡莎莎", "男", "徐友安", "男", "肖诗涛", "男", "王闯", "男", "余兴龙", "男", "芦荫杰", "男", "丁金富", "男", "谭军令", "女", "鄢旭燕", "男", "田坤", "男", "夏德胜", "男", "喻显发", "男", "马兴宝", "男", "孙学涛", "男", "陶云成", "男", "马远健", "男", "田华", "男", "聂子森", "男", "郑永军", "男", "余昌平", "男", "陶俊华", "男", "李小林", "男", "李荣宝", "男", "梅盈凯", "男", "张元群", "男", "郝新华", "男", "刘红涛", "男", "向志强", "男", "伍小峰", "男", "胡勇民", "男", "黄定祥", "女", "高红香", "男", "刘军", "男", "叶松", "男", "易俊林", "男", "张威", "男", "刘卫华", "男", "李浩", "男", "李寿庚", "男", "涂洋", "男", "曹晶", "男", "陈辉", "女", "彭博", "男", "严雪冰", "男", "刘青", "女", "印媛", "男", "吴道雄", "男", "邓旻", "男", "陈骏", "男", "崔波", "男", "韩静颐", "男", "严安勇", "男", "刘攀", "女", "刘艳", "女", "孙昕", "女", "郑新", "女", "徐睿", "女", "李月杰", "男", "吕焱鑫", "女", "刘沈", "男", "朱绍军", "女", "马茜", "女", "唐蕾", "女", "刘姣", "女", "于芳", "男", "吴健", "女", "张丹梅", "女", "王燕", "女", "贾兆梅", "男", "程柏漠", "男", "程辉", "女", "任明慧", "女", "焦莹", "女", "马淑娟", "男", "徐涛", "男", "孙庆国", "男", "刘胜", "女", "傅广凤", "男", "袁弘", "男", "高令旭", "男", "栾树权", "女", "申霞", "女", "韩文萍", "女", "隋艳", "男", "邢海洲", "女", "王宁", "女", "陈晶", "女", "吕翠", "女", "刘少敏", "女", "刘少君", "男", "孔鹏", "女", "张冰", "女", "王芳", "男", "万世忠", "女", "徐凡", "女", "张玉梅", "女", "何莉", "女", "时会云", "女", "王玉杰", "女", "谭素英", "女", "李艳红", "女", "刘素莉", "男", "王旭海", "女", "安丽梅", "女", "姚露", "女", "贾颖", "女", "曹微", "男", "黄经华", "女", "陈玉华", "女", "姜媛", "女", "魏立平", "女", "张萍", "男", "来辉", "女", "陈秀玫", "男", "石岩", "男", "王洪捍", "男", "张树军", "女", "李亚琴", "女", "王凤", "女", "王珊华", "女", "杨丹丹", "女", "教黎明", "女", "修晶", "女", "丁晓霞", "女", "张丽", "女", "郭素兰", "女", "徐艳丽", "女", "任子英", "女", "胡雁", "女", "彭洪亮", "女", "高玉珍", "女", "王玉姝", "男", "郑伟", "女", "姜春玲", "女", "张伟", "女", "王颖", "女", "金萍", "男", "孙望", "男", "闫宝东", "男", "周相永", "女", "杨美娜", "女", "欧立新", "女", "刘宝霞", "女", "刘艳杰", "女", "宋艳平", "男", "李克", "女", "梁翠", "女", "宗宏伟", "女", "刘国伟", "女", "敖志敏", "女", "尹玲" };
            string[] EMAIL_NAMES = { "qq.com", "gmail.com", "163.com", "126.com", "outlook.com", "foxmail.com" };

            var users = new List <User>();
            var rdm   = new Random();

            for (int i = 0, count = USER_NAMES.Length; i < count; i += 2)
            {
                string gender      = USER_NAMES[i];
                string chineseName = USER_NAMES[i + 1];
                string userName    = "******" + i.ToString();

                users.Add(new User
                {
                    Name        = userName,
                    Gender      = gender,
                    Password    = PasswordUtil.CreateDbPassword(userName),
                    ChineseName = chineseName,
                    Email       = userName + "@" + EMAIL_NAMES[rdm.Next(0, EMAIL_NAMES.Length)],
                    Enabled     = true,
                    CreateTime  = DateTime.Now
                });
            }

            // 添加超级管理员
            users.Add(new User
            {
                Name        = "admin",
                Gender      = "男",
                Password    = PasswordUtil.CreateDbPassword("admin"),
                ChineseName = "超级管理员",
                Email       = "*****@*****.**",
                Enabled     = true,
                CreateTime  = DateTime.Now
            });

            return(users);
        }
        private static List <User> GetUsers()
        {
            var users = new List <User>();

            users.Add(new User
            {
                Name        = "park",
                Gender      = "男",
                Password    = PasswordUtil.CreateDbPassword("park"),
                ChineseName = "停车场管理员",
                Email       = "",
                Enabled     = true,
                CreateTime  = DateTime.Now
            });
            users.Add(new User
            {
                Name        = "car",
                Gender      = "男",
                Password    = PasswordUtil.CreateDbPassword("car"),
                ChineseName = "业务管理员",
                Email       = "",
                Enabled     = true,
                CreateTime  = DateTime.Now
            });

            // 添加超级管理员
            users.Add(new User
            {
                Name        = "admin",
                Gender      = "男",
                Password    = PasswordUtil.CreateDbPassword("admin"),
                ChineseName = "超级管理员",
                Email       = "",
                Enabled     = true,
                CreateTime  = DateTime.Now
            });

            return(users);
        }
        protected void btnSave_OnClick(object sender, EventArgs e)
        {
            // 检查当前密码是否正确
            string oldPass        = tbxOldPassword.Text.Trim();
            string newPass        = tbxNewPassword.Text.Trim();
            string confirmNewPass = tbxConfirmNewPassword.Text.Trim();

            if (newPass != confirmNewPass)
            {
                tbxConfirmNewPassword.MarkInvalid("确认密码和新密码不一致!");
                return;
            }

            UserModel.ID = int.Parse(getUserID(GetIdentityName()));
            DataSet ds = XASYU.BLL.DataBaseQuery.query_SYS_USERS(userBean, UserModel, ref V_ITOTALCOUNT, 0, 20);

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
            {
                if (!PasswordUtil.ComparePasswords(ds.Tables[0].Rows[0]["Password"].ToString(), oldPass))
                {
                    tbxOldPassword.MarkInvalid("当前密码不正确!");
                    return;
                }
                string NewPassword = PasswordUtil.CreateDbPassword(newPass);
                string strWhere    = "ID=" + UserModel.ID;
                if (Common.UpdateTable("sys_Users", new string[] { "Password" }, new string[, ] {
                    { "" + NewPassword + "", "1" }
                }, strWhere) == 0)
                {
                    Alert.ShowInTop("修改密码成功!");
                }
                else
                {
                    Alert.ShowInTop("修改密码失败!");
                }
            }
        }
Beispiel #28
0
        private void SaveItem()
        {
            int companyID = UserInfo.Current.CompanyID;

            Infobasis.Data.DataEntity.User item = new Infobasis.Data.DataEntity.User();
            item.Name              = tbxName.Text.Trim();
            item.Password          = PasswordUtil.CreateDbPassword(tbxPassword.Text.Trim());
            item.ChineseName       = tbxRealName.Text.Trim();
            item.EmployeeSpellCode = ChinesePinyin.GetPinyin(tbxRealName.Text.Trim());
            item.FirstSpellCode    = ChinesePinyin.GetFirstPinyin(tbxRealName.Text.Trim());
            item.Email             = tbxEmail.Text.Trim();
            item.Remark            = tbxRemark.Text.Trim();
            item.Enabled           = cbxEnabled.Checked;
            item.CreateDatetime    = DateTime.Now;
            item.CompanyID         = companyID;
            item.UserType          = UserType.Employee;

            // 添加所有角色
            if (ddbRoles.Values != null)
            {
                item.UserPermissionRoles = new List <UserPermissionRole>();
                foreach (var roleID in ddbRoles.Values)
                {
                    item.UserPermissionRoles.Add(new UserPermissionRole()
                    {
                        UserID           = item.ID,
                        CompanyID        = companyID,
                        PermissionRoleID = Change.ToInt(roleID),
                        CreateDatetime   = DateTime.Now
                    });
                }
            }

            DB.Users.Add(item);
            DB.SaveChanges();
        }
Beispiel #29
0
        public ActionResult btnSave_OnClick()
        {
            // 检查当前密码是否正确
            string oldPass        = Request["tbxOldPassword"];
            string newPass        = Request["tbxNewPassword"];
            string confirmNewPass = Request["tbxConfirmNewPassword"];

            if (newPass != confirmNewPass)
            {
                UIHelper.TextBox("tbxConfirmNewPassword").MarkInvalid("确认密码和新密码不一致!");
            }

            if (!PasswordUtil.ComparePasswords(Panda_UserInfoDal.Get(GetIdentityName())["UserPwd"].ToString(), oldPass))
            {
                UIHelper.TextBox("tbxOldPassword").MarkInvalid("当前密码不正确!");
            }

            try
            {
                //string userGH = GetIdentityName();
                //User users = db.users.Where(x => x.Name.Equals(userGH)).FirstOrDefault();
                //users.Password = PasswordUtil.CreateDbPassword(newPass);
                //db.SaveChanges();
                Hashtable hasData = new Hashtable();
                hasData["ID"]      = GetIdentityName();
                hasData["UserPwd"] = PasswordUtil.CreateDbPassword(newPass);
                Panda_UserInfoDal.Update(hasData);
                ShowNotify("修改密码成功!");
            }
            catch
            {
                ShowNotify("修改密码失败,请重新操作!");
            }

            return(UIHelper.Result());
        }
Beispiel #30
0
        public async Task ModifyUserAsync(User user)
        {
            Check.IfNullOrZero(user);

            await Task.Run(() =>
            {
                using var mapper = EntityMapper.CreateMapper();
                {
                    mapper.OpenTransaction();
                    try
                    {
                        if (!String.IsNullOrEmpty(user.LoginPassword))
                        {
                            #region 修改密码
                            {
                                var newPassword = PasswordUtil.CreateDbPassword(user.LoginPassword);
                                user.ModifyLoginPassword(newPassword);
                                var result = mapper.Update(user, acc => acc.Id == user.Id);
                                if (!result)
                                {
                                    throw new BusinessException("修改登陆密码失败");
                                }
                            }
                            #endregion
                        }

                        #region 修改用户角色
                        {
                            var userRole = new UserRole();
                            userRole.Remove();
                            var result = mapper.Update(userRole, acc => acc.UserId == user.Id);
                            if (!result)
                            {
                                throw new BusinessException("移除用户角色失败");
                            }
                            if (user.Roles == null || !user.Roles.Any())
                            {
                                user.DetachAdminRole();
                            }
                            else
                            {
                                user.AttachAdminRole();
                                foreach (var item in user.Roles)
                                {
                                    mapper.Add(new UserRole(user.Id, item.RoleId));
                                }
                            }
                            var result2 = mapper.Update(user, ac => ac.Id == user.Id);
                            if (!result2)
                            {
                                throw new BusinessException("修改用户角色失败");
                            }
                        }
                        #endregion

                        mapper.Commit();
                    }
                    catch (Exception)
                    {
                        mapper.Rollback();
                        throw;
                    }
                }
            });
        }