public override void Submit_OnClick(object sender, EventArgs e) { try { ConfigManager.SystemConfigInfo.LoginUserNameMinLength = TranslateUtils.ToInt(TbLoginUserNameMinLength.Text); ConfigManager.SystemConfigInfo.LoginPasswordMinLength = TranslateUtils.ToInt(TbLoginPasswordMinLength.Text); ConfigManager.SystemConfigInfo.LoginPasswordRestriction = EUserPasswordRestrictionUtils.GetEnumType(DdlLoginPasswordRestriction.SelectedValue); ConfigManager.SystemConfigInfo.IsLoginFailToLock = TranslateUtils.ToBool(RblIsLoginFailToLock.SelectedValue); ConfigManager.SystemConfigInfo.LoginFailToLockCount = TranslateUtils.ToInt(TbLoginFailToLockCount.Text, 3); ConfigManager.SystemConfigInfo.LoginLockingType = DdlLoginLockingType.SelectedValue; ConfigManager.SystemConfigInfo.LoginLockingHours = TranslateUtils.ToInt(TbLoginLockingHours.Text); ConfigManager.SystemConfigInfo.IsFindPassword = TranslateUtils.ToBool(RblIsFindPassword.SelectedValue); ConfigManager.SystemConfigInfo.FindPasswordSmsTplId = TbFindPasswordSmsTplId.Text; ConfigManager.SystemConfigInfo.IsViewContentOnlySelf = TranslateUtils.ToBool(RblIsViewContentOnlySelf.SelectedValue); BaiRongDataProvider.ConfigDao.Update(ConfigManager.Instance); Body.AddAdminLog("管理员设置"); SuccessMessage("管理员设置成功"); } catch (Exception ex) { FailMessage(ex, ex.Message); } }
public bool ChangePassword(string userName, string password, out string errorMessage) { errorMessage = string.Empty; if (string.IsNullOrEmpty(password)) { errorMessage = "密码不能为空"; return(false); } if (password.Length < ConfigManager.SystemConfigInfo.AdminPasswordMinLength) { errorMessage = $"密码长度必须大于等于{ConfigManager.SystemConfigInfo.AdminPasswordMinLength}"; return(false); } if ( !EUserPasswordRestrictionUtils.IsValid(password, ConfigManager.SystemConfigInfo.AdminPasswordRestriction)) { errorMessage = $"密码不符合规则,请包含{EUserPasswordRestrictionUtils.GetText(EUserPasswordRestrictionUtils.GetEnumType(ConfigManager.SystemConfigInfo.AdminPasswordRestriction))}"; return(false); } string passwordSalt; password = EncodePassword(password, EPasswordFormat.Encrypted, out passwordSalt); return(ChangePassword(userName, EPasswordFormat.Encrypted, passwordSalt, password)); }
public override void Submit_OnClick(object sender, EventArgs e) { if (Page.IsPostBack && Page.IsValid) { ConfigManager.UserConfigInfo.IsRegisterAllowed = TranslateUtils.ToBool(RblIsRegisterAllowed.SelectedValue); ConfigManager.UserConfigInfo.RegisterPasswordMinLength = TranslateUtils.ToInt(TbRegisterPasswordMinLength.Text); ConfigManager.UserConfigInfo.RegisterPasswordRestriction = EUserPasswordRestrictionUtils.GetEnumType(DdlRegisterPasswordRestriction.SelectedValue); ConfigManager.UserConfigInfo.RegisterVerifyType = EUserVerifyTypeUtils.GetEnumType(DdlRegisterVerifyType.SelectedValue); ConfigManager.UserConfigInfo.RegisterMinMinutesOfIpAddress = TranslateUtils.ToInt(TbRegisterMinMinutesOfIpAddress.Text); try { BaiRongDataProvider.ConfigDao.Update(ConfigManager.Instance); Body.AddAdminLog("修改用户注册设置"); SuccessMessage("设置修改成功!"); } catch (Exception ex) { FailMessage(ex, "设置修改失败!"); } } }
private bool InsertValidate(string userName, string email, string mobile, string password, string ipAddress, out string errorMessage) { errorMessage = string.Empty; if (!UserManager.IsIpAddressCached(ipAddress)) { errorMessage = $"同一IP在{ConfigManager.SystemConfigInfo.UserRegistrationMinMinutes}分钟内只能注册一次"; return(false); } if (string.IsNullOrEmpty(password)) { errorMessage = "密码不能为空"; return(false); } if (password.Length < ConfigManager.SystemConfigInfo.UserPasswordMinLength) { errorMessage = $"密码长度必须大于等于{ConfigManager.SystemConfigInfo.UserPasswordMinLength}"; return(false); } if (!EUserPasswordRestrictionUtils.IsValid(password, ConfigManager.SystemConfigInfo.UserPasswordRestriction)) { errorMessage = $"密码不符合规则,请包含{EUserPasswordRestrictionUtils.GetText(EUserPasswordRestrictionUtils.GetEnumType(ConfigManager.SystemConfigInfo.UserPasswordRestriction))}"; return(false); } if (string.IsNullOrEmpty(userName)) { errorMessage = "用户名为空,请填写用户名"; return(false); } if (!string.IsNullOrEmpty(userName) && IsUserNameExists(userName)) { errorMessage = "用户名已被注册,请更换用户名"; return(false); } if (!IsUserNameCompliant(userName.Replace("@", string.Empty).Replace(".", string.Empty))) { errorMessage = "用户名包含不规则字符,请更换用户名"; return(false); } if (!string.IsNullOrEmpty(email) && IsEmailExists(email)) { errorMessage = "电子邮件地址已被注册,请更换邮箱"; return(false); } if (!string.IsNullOrEmpty(mobile) && IsMobileExists(mobile)) { errorMessage = "手机号码已被注册,请更换手机号码"; return(false); } return(true); }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } _userId = AuthRequest.GetQueryInt("userID"); _returnUrl = StringUtils.ValueFromUrl(AuthRequest.GetQueryString("returnUrl")); if (IsPostBack) { return; } VerifySystemPermissions(ConfigManager.AppPermissions.SettingsUser); LtlPageTitle.Text = _userId == 0 ? "添加用户" : "编辑用户"; foreach (var groupInfo in UserGroupManager.GetUserGroupInfoList()) { DdlGroupId.Items.Add(new ListItem(groupInfo.GroupName, groupInfo.Id.ToString())); } if (_userId > 0) { var userInfo = UserManager.GetUserInfoByUserId(_userId); if (userInfo != null) { TbUserName.Text = userInfo.UserName; ControlUtils.SelectSingleItem(DdlGroupId, userInfo.GroupId.ToString()); TbUserName.Enabled = false; TbDisplayName.Text = userInfo.DisplayName; PhPassword.Visible = false; TbEmail.Text = userInfo.Email; TbMobile.Text = userInfo.Mobile; } } if (!EUserPasswordRestrictionUtils.Equals(ConfigManager.SystemConfigInfo.UserPasswordRestriction, EUserPasswordRestriction.None)) { LtlPasswordTips.Text = $"请包含{EUserPasswordRestrictionUtils.GetText(EUserPasswordRestrictionUtils.GetEnumType(ConfigManager.SystemConfigInfo.UserPasswordRestriction))}"; } if (!string.IsNullOrEmpty(_returnUrl)) { BtnReturn.Attributes.Add("onclick", $"window.location.href='{_returnUrl}';return false;"); } else { BtnReturn.Visible = false; } }
public bool Insert(AdministratorInfo userInfo, out string errorMessage) { errorMessage = string.Empty; if (string.IsNullOrEmpty(userInfo.UserName)) { errorMessage = "用户名不能为空"; return(false); } if (userInfo.UserName.Length < ConfigManager.SystemConfigInfo.AdminUserNameMinLength) { errorMessage = $"用户名长度必须大于等于{ConfigManager.SystemConfigInfo.AdminUserNameMinLength}"; return(false); } if (IsAdminNameExists(userInfo.UserName)) { errorMessage = "用户名已存在,请更换用户名"; return(false); } if (string.IsNullOrEmpty(userInfo.Password)) { errorMessage = "密码不能为空"; return(false); } if (userInfo.Password.Length < ConfigManager.SystemConfigInfo.AdminPasswordMinLength) { errorMessage = $"密码长度必须大于等于{ConfigManager.SystemConfigInfo.AdminPasswordMinLength}"; return(false); } if ( !EUserPasswordRestrictionUtils.IsValid(userInfo.Password, ConfigManager.SystemConfigInfo.AdminPasswordRestriction)) { errorMessage = $"密码不符合规则,请包含{EUserPasswordRestrictionUtils.GetText(EUserPasswordRestrictionUtils.GetEnumType(ConfigManager.SystemConfigInfo.AdminPasswordRestriction))}"; return(false); } try { string passwordSalt; userInfo.Password = EncodePassword(userInfo.Password, userInfo.PasswordFormat, out passwordSalt); userInfo.PasswordSalt = passwordSalt; Insert(userInfo); return(true); } catch (Exception ex) { errorMessage = ex.Message; return(false); } }
private bool InsertValidate(string userName, string password, string email, string mobile, out string errorMessage) { errorMessage = string.Empty; if (string.IsNullOrEmpty(userName)) { errorMessage = "用户名不能为空"; return(false); } if (userName.Length < ConfigManager.SystemConfigInfo.AdminUserNameMinLength) { errorMessage = $"用户名长度必须大于等于{ConfigManager.SystemConfigInfo.AdminUserNameMinLength}"; return(false); } if (IsUserNameExists(userName)) { errorMessage = "用户名已存在,请更换用户名"; return(false); } if (string.IsNullOrEmpty(password)) { errorMessage = "密码不能为空"; return(false); } if (password.Length < ConfigManager.SystemConfigInfo.AdminPasswordMinLength) { errorMessage = $"密码长度必须大于等于{ConfigManager.SystemConfigInfo.AdminPasswordMinLength}"; return(false); } if ( !EUserPasswordRestrictionUtils.IsValid(password, ConfigManager.SystemConfigInfo.AdminPasswordRestriction)) { errorMessage = $"密码不符合规则,请包含{EUserPasswordRestrictionUtils.GetText(EUserPasswordRestrictionUtils.GetEnumType(ConfigManager.SystemConfigInfo.AdminPasswordRestriction))}"; return(false); } if (!string.IsNullOrEmpty(email) && IsEmailExists(email)) { errorMessage = "电子邮件地址已被注册,请更换邮箱"; return(false); } if (!string.IsNullOrEmpty(mobile) && IsMobileExists(mobile)) { errorMessage = "手机号码已被注册,请更换手机号码"; return(false); } return(true); }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } _userId = Body.GetQueryInt("userID"); _returnUrl = StringUtils.ValueFromUrl(Body.GetQueryString("returnUrl")); if (IsPostBack) { return; } VerifyAdministratorPermissions(ConfigManager.Permissions.Settings.User); LtlPageTitle.Text = _userId == 0 ? "添加用户" : "编辑用户"; if (_userId > 0) { var userInfo = DataProvider.UserDao.GetUserInfo(_userId); if (userInfo != null) { TbUserName.Text = userInfo.UserName; TbUserName.Enabled = false; TbDisplayName.Text = userInfo.DisplayName; PhPassword.Visible = false; TbEmail.Text = userInfo.Email; TbMobile.Text = userInfo.Mobile; } } if (!EUserPasswordRestrictionUtils.Equals(ConfigManager.SystemConfigInfo.UserPasswordRestriction, EUserPasswordRestriction.None)) { LtlPasswordTips.Text = $"请包含{EUserPasswordRestrictionUtils.GetText(EUserPasswordRestrictionUtils.GetEnumType(ConfigManager.SystemConfigInfo.UserPasswordRestriction))}"; } if (!string.IsNullOrEmpty(_returnUrl)) { BtnReturn.Attributes.Add("onclick", $"window.location.href='{_returnUrl}';return false;"); } else { BtnReturn.Visible = false; } }
public bool IsPasswordCorrect(string password, out string errorMessage) { errorMessage = null; if (string.IsNullOrEmpty(password)) { errorMessage = "密码不能为空"; return(false); } if (password.Length < ConfigManager.SystemConfigInfo.UserPasswordMinLength) { errorMessage = $"密码长度必须大于等于{ConfigManager.SystemConfigInfo.UserPasswordMinLength}"; return(false); } if (!EUserPasswordRestrictionUtils.IsValid(password, ConfigManager.SystemConfigInfo.UserPasswordRestriction)) { errorMessage = $"密码不符合规则,请包含{EUserPasswordRestrictionUtils.GetText(EUserPasswordRestrictionUtils.GetEnumType(ConfigManager.SystemConfigInfo.UserPasswordRestriction))}"; return(false); } return(true); }
public bool ChangePassword(string userName, string password, out string errorMessage) { errorMessage = null; if (password.Length < ConfigManager.SystemConfigInfo.UserPasswordMinLength) { errorMessage = $"密码长度必须大于等于{ConfigManager.SystemConfigInfo.UserPasswordMinLength}"; return(false); } if (!EUserPasswordRestrictionUtils.IsValid(password, ConfigManager.SystemConfigInfo.UserPasswordRestriction)) { errorMessage = $"密码不符合规则,请包含{EUserPasswordRestrictionUtils.GetText(EUserPasswordRestrictionUtils.GetEnumType(ConfigManager.SystemConfigInfo.UserPasswordRestriction))}"; return(false); } var passwordFormat = EPasswordFormat.Encrypted; var passwordSalt = GenerateSalt(); password = EncodePassword(password, passwordFormat, passwordSalt); ChangePassword(userName, passwordFormat, passwordSalt, password); return(true); }