Kaynağa Gözat

账户锁定新增解锁功能

cain 5 yıl önce
ebeveyn
işleme
f4ab77f80a

+ 15 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysLogininforController.java

@@ -1,6 +1,8 @@
 package com.ruoyi.web.controller.monitor;
 
 import java.util.List;
+
+import com.ruoyi.framework.shiro.service.SysPasswordService;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
@@ -31,6 +33,9 @@ public class SysLogininforController extends BaseController
     @Autowired
     private ISysLogininforService logininforService;
 
+    @Autowired
+    private SysPasswordService passwordService;
+
     @RequiresPermissions("monitor:logininfor:view")
     @GetMapping()
     public String logininfor()
@@ -77,4 +82,14 @@ public class SysLogininforController extends BaseController
         logininforService.cleanLogininfor();
         return success();
     }
+
+    @RequiresPermissions("monitor:logininfor:unlock")
+    @Log(title = "账户解锁", businessType = BusinessType.OTHER)
+    @PostMapping("/unlock")
+    @ResponseBody
+    public AjaxResult unlock(String loginName)
+    {
+        passwordService.unlock(loginName);
+        return success();
+    }
 }

+ 2 - 2
ruoyi-admin/src/main/resources/static/i18n/messages.properties

@@ -1,8 +1,8 @@
 #错误消息
 not.null=* 必须填写
 user.jcaptcha.error=验证码错误
-user.not.exists=用户不存在/密码错误
-user.password.not.match=用户不存在/密码错误
+user.not.exists=用户不存在
+user.password.not.match=密码错误
 user.password.retry.limit.count=密码输入错误{0}次
 user.password.retry.limit.exceed=密码输入错误{0}次,帐户锁定10分钟
 user.password.delete=对不起,您的账号已被删除

+ 7 - 0
ruoyi-admin/src/main/resources/templates/monitor/logininfor/logininfor.html

@@ -44,6 +44,9 @@
 		        <a class="btn btn-danger" onclick="$.operate.clean()" shiro:hasPermission="monitor:logininfor:remove">
 	                <i class="fa fa-trash"></i> 清空
 	            </a>
+				<a class="btn btn-primary single disabled" onclick="unlock()" shiro:hasPermission="monitor:logininfor:unlock">
+					<i class="fa fa-unlock"></i> 解锁
+				</a>
 	            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="monitor:logininfor:export">
 		            <i class="fa fa-download"></i> 导出
 		        </a>
@@ -121,6 +124,10 @@
 		    };
 		    $.table.init(options);
 		});
+		
+		function unlock() {
+            $.operate.post(prefix + "/unlock?loginName=" + $.table.selectColumns("loginName"));
+        }
 	</script>
 </body>
 </html>

+ 4 - 0
ruoyi-framework/src/main/java/com/ruoyi/framework/shiro/service/SysPasswordService.java

@@ -83,4 +83,8 @@ public class SysPasswordService
         return new Md5Hash(username + password + salt).toHex().toString();
     }
 
+    public void unlock(String loginName){
+        loginRecordCache.remove(loginName);
+    }
+
 }

+ 2 - 0
sql/ry_20190920.sql

@@ -231,6 +231,7 @@ insert into sys_menu values('1042', '日志导出', '500', '4', '#', '',  'F', '
 insert into sys_menu values('1043', '登录查询', '501', '1', '#', '',  'F', '0', 'monitor:logininfor:list',         '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
 insert into sys_menu values('1044', '登录删除', '501', '2', '#', '',  'F', '0', 'monitor:logininfor:remove',       '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
 insert into sys_menu values('1045', '日志导出', '501', '3', '#', '',  'F', '0', 'monitor:logininfor:export',       '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
+insert into sys_menu values('1061', '账户解锁', '501', '4', '#', '',  'F', '0', 'monitor:logininfor:unlock',       '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
 -- 在线用户按钮
 insert into sys_menu values('1046', '在线查询', '109', '1', '#', '',  'F', '0', 'monitor:online:list',             '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
 insert into sys_menu values('1047', '批量强退', '109', '2', '#', '',  'F', '0', 'monitor:online:batchForceLogout', '#', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '');
@@ -363,6 +364,7 @@ insert into sys_role_menu values ('2', '1057');
 insert into sys_role_menu values ('2', '1058');
 insert into sys_role_menu values ('2', '1059');
 insert into sys_role_menu values ('2', '1060');
+insert into sys_role_menu values ('2', '1061');
 
 -- ----------------------------
 -- 8、角色和部门关联表  角色1-N部门