更新组件,增加密码强度配置
This commit is contained in:
@@ -14,6 +14,8 @@ using Microsoft.AspNetCore.Hosting;
|
||||
using System.IO;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Web;
|
||||
using COMCMS.Web.Models;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
{
|
||||
@@ -23,6 +25,16 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
[DisplayName("管理员")]
|
||||
public class MemberController : AdminBaseController
|
||||
{
|
||||
private readonly SystemSetting _systemSetting;
|
||||
private IWebHostEnvironment _env;
|
||||
private AttachConfigEntity attach;
|
||||
public MemberController(IWebHostEnvironment env, IOptions<SystemSetting> systemSetting)
|
||||
{
|
||||
attach = Config.GetSystemConfig().AttachConfigEntity;
|
||||
_env = env;
|
||||
_systemSetting = systemSetting.Value;
|
||||
}
|
||||
|
||||
#region 修改密码
|
||||
//修改个人信息
|
||||
[MyAuthorize("view", "editme")]
|
||||
@@ -30,6 +42,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
{
|
||||
Core.Admin my = Core.Admin.GetMyInfo();
|
||||
Core.Admin.WriteLogActions("查看/编辑我的信息;");
|
||||
ViewBag.passwordTip = Utils.GetPasswordStrengthTip(_systemSetting.PasswordStrength);
|
||||
return View(my);
|
||||
}
|
||||
[HttpPost]
|
||||
@@ -88,6 +101,15 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
tip.Message = "新密码不能小于5个字符!";
|
||||
return Json(tip);
|
||||
}
|
||||
|
||||
if (_systemSetting.PasswordStrength > 0)
|
||||
{
|
||||
if (!Utils.CheckPasswordStrength(newPwd, _systemSetting.PasswordStrength))
|
||||
{
|
||||
tip.Message = $"您的密码强度不符合要求:{Utils.GetPasswordStrengthTip(_systemSetting.PasswordStrength)}!";
|
||||
return Json(tip);
|
||||
}
|
||||
}
|
||||
if (newPwd != renewPwd)
|
||||
{
|
||||
tip.Message = "您输入的两次密码不一样!";
|
||||
@@ -491,6 +513,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
//加载管理组
|
||||
IList<AdminRoles> list = AdminRoles.FindAll(AdminRoles._.Id > 0, AdminRoles._.Rank.Asc(), null, 0, 0);
|
||||
ViewBag.RoleList = list;
|
||||
ViewBag.passwordTip = Utils.GetPasswordStrengthTip(_systemSetting.PasswordStrength);
|
||||
Core.Admin.WriteLogActions("查看添加管理员页面;");
|
||||
return View();
|
||||
}
|
||||
@@ -531,11 +554,20 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
tip.Message = "密码不能小于5个字符!";
|
||||
return Json(tip);
|
||||
}
|
||||
if (_systemSetting.PasswordStrength > 0)
|
||||
{
|
||||
if (!Utils.CheckPasswordStrength(newPwd, _systemSetting.PasswordStrength))
|
||||
{
|
||||
tip.Message = $"您的密码强度不符合要求:{Utils.GetPasswordStrengthTip(_systemSetting.PasswordStrength)}!";
|
||||
return Json(tip);
|
||||
}
|
||||
}
|
||||
if (newPwd != renewPwd)
|
||||
{
|
||||
tip.Message = "两次输入密码不一致,请重新输入!";
|
||||
return Json(tip);
|
||||
}
|
||||
|
||||
//验证用户名
|
||||
if (Core.Admin.FindCount(Core.Admin._.UserName == userName, null, null, 0, 0) > 0)
|
||||
{
|
||||
@@ -570,6 +602,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
{
|
||||
return EchoTipPage("系统找不到本记录!");
|
||||
}
|
||||
ViewBag.passwordTip = Utils.GetPasswordStrengthTip(_systemSetting.PasswordStrength);
|
||||
Core.Admin.WriteLogActions($"查看/编辑管理员({entity.UserName});");
|
||||
return View(entity);
|
||||
}
|
||||
@@ -628,6 +661,14 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
tip.Message = "密码不能小于5个字符!";
|
||||
return Json(tip);
|
||||
}
|
||||
if (_systemSetting.PasswordStrength > 0)
|
||||
{
|
||||
if (!Utils.CheckPasswordStrength(newPwd, _systemSetting.PasswordStrength))
|
||||
{
|
||||
tip.Message = $"您的密码强度不符合要求:{Utils.GetPasswordStrengthTip(_systemSetting.PasswordStrength)}!";
|
||||
return Json(tip);
|
||||
}
|
||||
}
|
||||
if (newPwd != renewPwd)
|
||||
{
|
||||
tip.Message = "两次输入密码不一致,请重新输入!";
|
||||
@@ -918,7 +959,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
IList<MemberRoles> list = MemberRoles.FindAll(MemberRoles._.Id > 0, MemberRoles._.Rank.Asc(), null, 0, 0);
|
||||
ViewBag.RoleList = list;
|
||||
ViewBag.allmember = Member.FindAll(Member._.Id > 0 & Member._.IsLock != 1, null, null, 0, 0);
|
||||
|
||||
ViewBag.passwordTip = Utils.GetPasswordStrengthTip(_systemSetting.PasswordStrength);
|
||||
Core.Admin.WriteLogActions($"查看添加用户页面;");
|
||||
Member model = new Member();
|
||||
return View(model);
|
||||
@@ -944,6 +985,15 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
tip.Message = "密码必须不小于6个字符";
|
||||
return Json(tip);
|
||||
}
|
||||
if (_systemSetting.PasswordStrength > 0)
|
||||
{
|
||||
if (!Utils.CheckPasswordStrength(model.PassWord, _systemSetting.PasswordStrength))
|
||||
{
|
||||
tip.Message = $"您的密码强度不符合要求:{Utils.GetPasswordStrengthTip(_systemSetting.PasswordStrength)}!";
|
||||
return Json(tip);
|
||||
}
|
||||
}
|
||||
|
||||
string PassWord2 = Request.Form["PassWord2"];
|
||||
if (model.PassWord != PassWord2)
|
||||
{
|
||||
@@ -1014,7 +1064,7 @@ namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
IList<RebateChangeLog> listrechargebalancelogs = RebateChangeLog.FindAll(RebateChangeLog._.UId == entity.Id, null, null, 0, 0);
|
||||
ViewBag.listrechargebalancelogs = listrechargebalancelogs;
|
||||
|
||||
|
||||
ViewBag.passwordTip = Utils.GetPasswordStrengthTip(_systemSetting.PasswordStrength);
|
||||
|
||||
Core.Admin.WriteLogActions($"查看/编辑用户({entity.UserName});");
|
||||
return View(entity);
|
||||
|
||||
@@ -12,6 +12,10 @@
|
||||
<div class="ibox-content">
|
||||
@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "addAdminForm", @class = "form-horizontal m-t" }))
|
||||
{
|
||||
<div class="alert alert-info">
|
||||
您可以修改密码,请务必设置一个比较复杂的密码,以免被爆破!<br />
|
||||
密码要求:<span class="text-danger">@ViewBag.passwordTip</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">所属管理组:</label>
|
||||
<div class="col-sm-8">
|
||||
@@ -26,7 +30,7 @@
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">用户名:</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="UserName" name="UserName" maxlength="20" type="text" class="form-control" required aria-required="true" placeholder="填写管理员登录用户名">
|
||||
<input id="UserName" name="UserName" maxlength="20" type="text" class="form-control" required aria-required="true" placeholder="填写管理员登录用户名" autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -38,13 +42,13 @@
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">登录密码:</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="PassWord" name="PassWord" maxlength="20" type="password" class="form-control" placeholder="填写管理员登录密码" required>
|
||||
<input id="PassWord" name="PassWord" maxlength="20" type="password" class="form-control" placeholder="填写管理员登录密码" required autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">重复密码:</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="PassWord2" type="password" class="form-control" name="PassWord2" maxlength="20" placeholder="请重复填写一次登录密码" aria-required="true" required>
|
||||
<input id="PassWord2" type="password" class="form-control" name="PassWord2" maxlength="20" placeholder="请重复填写一次登录密码" aria-required="true" required autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -12,6 +12,10 @@
|
||||
<div class="ibox-content">
|
||||
@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "editAdminForm", @class = "form-horizontal m-t" }))
|
||||
{
|
||||
<div class="alert alert-info">
|
||||
您可以修改密码,请务必设置一个比较复杂的密码,以免被爆破!<br />
|
||||
密码要求:<span class="text-danger">@ViewBag.passwordTip</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">所属管理组:</label>
|
||||
<div class="col-sm-8">
|
||||
@@ -38,13 +42,13 @@
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">登录密码:</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="PassWord" name="PassWord" maxlength="20" type="password" class="form-control" placeholder="如果修改密码,则请输入,否则,请留空">
|
||||
<input id="PassWord" name="PassWord" maxlength="20" type="password" class="form-control" placeholder="如果修改密码,则请输入,否则,请留空" autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">重复密码:</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="PassWord2" type="password" class="form-control" name="PassWord2" maxlength="20" placeholder="请重复填写一次登录密码">
|
||||
<input id="PassWord2" type="password" class="form-control" name="PassWord2" maxlength="20" placeholder="请重复填写一次登录密码" autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -14,33 +14,34 @@
|
||||
<div id="tab-1" class="tab-pane active">
|
||||
<div class="panel-body">
|
||||
<div class="alert alert-info">
|
||||
您可以修改密码,请务必设置一个比较复杂的密码,以免被爆破!
|
||||
您可以修改密码,请务必设置一个比较复杂的密码,以免被爆破!<br />
|
||||
密码要求:<span class="text-danger">@ViewBag.passwordTip</span>
|
||||
</div>
|
||||
@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "editmyinfoForm", @class = "form-horizontal m-t" }))
|
||||
{
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">用户名:</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="UserName" name="UserName" minlength="2" maxlength="20" type="text" class="form-control" required aria-required="true" placeholder="用户名,可以中英文,但不能少于5个字符" value="@Model.UserName">
|
||||
<input id="UserName" name="UserName" minlength="2" maxlength="20" type="text" class="form-control" required aria-required="true" placeholder="用户名,可以中英文,但不能少于5个字符" value="@Model.UserName" autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">旧密码:</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="txtOldPwd" name="txtOldPwd" type="password" class="form-control" placeholder="如果修改密码,则必须填写,否则,请留空" value="">
|
||||
<input id="txtOldPwd" name="txtOldPwd" type="password" class="form-control" placeholder="如果修改密码,则必须填写,否则,请留空" value="" autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">新密码:</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="txtNewPwd" name="txtNewPwd" type="password" class="form-control" placeholder="如果修改登录密码,请填写,否则,请留空" value="">
|
||||
<input id="txtNewPwd" name="txtNewPwd" type="password" class="form-control" placeholder="如果修改登录密码,请填写,否则,请留空" value="" autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">重复新密码:</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="txtreNewPwd" name="txtreNewPwd" type="password" class="form-control" placeholder="如果修改密码,请重复输入一次新密码,否则请流控" value="">
|
||||
<input id="txtreNewPwd" name="txtreNewPwd" type="password" class="form-control" placeholder="如果修改密码,请重复输入一次新密码,否则请流控" value="" autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user