【modify】页面过期自动刷新页面
This commit is contained in:
+2
@@ -71,6 +71,8 @@ public class CommonConstant {
|
||||
public static final Integer SC_INTERNAL_SERVER_ERROR_500 = 500;
|
||||
/** {@code 200 OK} (HTTP/1.0 - RFC 1945) */
|
||||
public static final Integer SC_OK_200 = 200;
|
||||
/** {@code 600 OK} (自编,RSA过期) */
|
||||
public static final Integer SC_RSA_TIMEOUT_600 = 600;
|
||||
|
||||
/**访问权限认证未通过 510*/
|
||||
public static final Integer SC_JERO_NO_AUTHZ=510;
|
||||
|
||||
-11
@@ -69,7 +69,6 @@ public class SysPermissionController {
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
@RequiresPermissions("permission:list")
|
||||
public Results<List<SysPermissionTree>> list() {
|
||||
long start = System.currentTimeMillis();
|
||||
Results<List<SysPermissionTree>> result = new Results<>();
|
||||
@@ -96,7 +95,6 @@ public class SysPermissionController {
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getSystemMenuList")
|
||||
@RequiresPermissions("permission:list")
|
||||
public Results<List<SysPermissionTree>> getSystemMenuList() {
|
||||
long start = System.currentTimeMillis();
|
||||
Results<List<SysPermissionTree>> result = new Results<>();
|
||||
@@ -126,7 +124,6 @@ public class SysPermissionController {
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getSystemSubmenu")
|
||||
@RequiresPermissions("permission:list")
|
||||
public Results<List<SysPermissionTree>> getSystemSubmenu(@RequestParam("parentId") String parentId){
|
||||
Results<List<SysPermissionTree>> result = new Results<>();
|
||||
try{
|
||||
@@ -157,7 +154,6 @@ public class SysPermissionController {
|
||||
* @return 返回 key-value 的 Map
|
||||
*/
|
||||
@GetMapping("/getSystemSubmenuBatch")
|
||||
@RequiresPermissions("permission:list")
|
||||
public Results<Map<String, List<SysPermissionTree>>> getSystemSubmenuBatch(@RequestParam("parentIds") String parentIds) {
|
||||
try {
|
||||
LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<>();
|
||||
@@ -191,7 +187,6 @@ public class SysPermissionController {
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getUserPermissionByToken")
|
||||
@RequiresPermissions("permission:list")
|
||||
public Results<JSONObject> getUserPermissionByToken() {
|
||||
Results<JSONObject> result = new Results<>();
|
||||
try {
|
||||
@@ -322,7 +317,6 @@ public class SysPermissionController {
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryTreeList")
|
||||
@RequiresPermissions("permission:list")
|
||||
public Results<Map<String, Object>> queryTreeList() {
|
||||
Results<Map<String, Object>> result = new Results<>();
|
||||
// 全部权限ids
|
||||
@@ -355,7 +349,6 @@ public class SysPermissionController {
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryListAsync")
|
||||
@RequiresPermissions("permission:list")
|
||||
public Results<List<TreeModel>> queryAsync(@RequestParam(name = "pid", required = false) String parentId) {
|
||||
Results<List<TreeModel>> result = new Results<>();
|
||||
try {
|
||||
@@ -379,7 +372,6 @@ public class SysPermissionController {
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryRolePermission")
|
||||
@RequiresPermissions("permission:list")
|
||||
public Results<List<String>> queryRolePermission(@RequestParam(name = "roleId", required = true) String roleId) {
|
||||
Results<List<String>> result = new Results<>();
|
||||
try {
|
||||
@@ -669,7 +661,6 @@ public class SysPermissionController {
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getPermRuleListByPermId")
|
||||
@RequiresPermissions("permission:list")
|
||||
public Results<List<SysPermissionDataRule>> getPermRuleListByPermId(SysPermissionDataRule sysPermissionDataRule) {
|
||||
List<SysPermissionDataRule> permRuleList = sysPermissionDataRuleService.getPermRuleListByPermId(sysPermissionDataRule.getPermissionId());
|
||||
Results<List<SysPermissionDataRule>> result = new Results<>();
|
||||
@@ -741,7 +732,6 @@ public class SysPermissionController {
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryPermissionRule")
|
||||
@RequiresPermissions("permission:list")
|
||||
public Results<List<SysPermissionDataRule>> queryPermissionRule(SysPermissionDataRule sysPermissionDataRule) {
|
||||
try {
|
||||
List<SysPermissionDataRule> permRuleList = sysPermissionDataRuleService.queryPermissionRule(sysPermissionDataRule);
|
||||
@@ -758,7 +748,6 @@ public class SysPermissionController {
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryDepartPermission")
|
||||
@RequiresPermissions("permission:list")
|
||||
public Results<List<String>> queryDepartPermission(@RequestParam(name = "departId", required = true) String departId) {
|
||||
Results<List<String>> result = new Results<>();
|
||||
try {
|
||||
|
||||
+23
-17
@@ -80,25 +80,21 @@ public class LoginServiceImpl implements ILoginService {
|
||||
String rsaPrivateKey = redisUtil.get(rsaPublicKey) != null ? String.valueOf(redisUtil.get(rsaPublicKey)) : null;
|
||||
|
||||
if(StrUtil.isEmpty(rsaPrivateKey)){
|
||||
return Results.error("页面过期,请刷新页面");
|
||||
· return Results.error(CommonConstant.SC_RSA_TIMEOUT_600, "页面过期,将刷新页面");
|
||||
}
|
||||
|
||||
//update-begin--Author:scott Date:20190805 for:暂时注释掉密码加密逻辑,有点问题
|
||||
//前端密码加密,后端进行密码解密
|
||||
//password = AesEncryptUtil.desEncrypt(sysLoginModel.getPassword().replaceAll("%2B", "\\+")).trim();//密码解密
|
||||
//update-begin--Author:scott Date:20190805 for:暂时注释掉密码加密逻辑,有点问题
|
||||
//update-begin-author:taoyan date:20190828 for:校验验证码
|
||||
String captcha = sysLoginModel.getCaptcha();
|
||||
if(captcha==null){
|
||||
return Results.error("验证码无效");
|
||||
}
|
||||
String lowerCaseCaptcha = captcha.toLowerCase();
|
||||
String realKey = MD5Util.MD5Encode(lowerCaseCaptcha+sysLoginModel.getCheckKey(), UTF_8);
|
||||
String realKey = MD5Util.MD5Encode(lowerCaseCaptcha + sysLoginModel.getCheckKey(), UTF_8);
|
||||
Object checkCode = redisUtil.get(realKey);
|
||||
//当进入登录页时,有一定几率出现验证码错误 #1714
|
||||
if(checkCode==null || !checkCode.toString().equals(lowerCaseCaptcha)) {
|
||||
// 验证码前后端比较
|
||||
if(checkCode == null || !checkCode.toString().equals(lowerCaseCaptcha)) {
|
||||
return Results.error("验证码错误");
|
||||
}
|
||||
|
||||
try {
|
||||
//解密获取密码和用户名
|
||||
password = CommonUtils.decryptBtRsaPriKey(password, rsaPrivateKey);
|
||||
@@ -106,6 +102,7 @@ public class LoginServiceImpl implements ILoginService {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//1. 校验用户是否有效
|
||||
//update-begin-author:wangshuai date:20200601 for: 登录代码验证用户是否注销bug,if条件永远为false
|
||||
LambdaQueryWrapper<SysUser> queryWrapper = new LambdaQueryWrapper<>();
|
||||
@@ -131,9 +128,8 @@ public class LoginServiceImpl implements ILoginService {
|
||||
if (!syspassword.equals(userpassword)) {
|
||||
// 重试登录次数加一
|
||||
retryCount++;
|
||||
setRedis(username, retryCount);
|
||||
//String msg = retryCount == RETRY_LOGIN_MAX_COUNT ? "密码错误次数过多,请稍后重试":"用户名或密码错误,剩余可登录次数:"+(RETRY_LOGIN_MAX_COUNT - retryCount);
|
||||
String msg = retryCount == RETRY_LOGIN_MAX_COUNT ? "密码错误次数过多,请稍后重试":"用户名或密码错误";
|
||||
this.setRetryInfoToRedis(username, retryCount);
|
||||
String msg = retryCount == RETRY_LOGIN_MAX_COUNT ? "密码错误次数过多,请稍后重试":"用户名或密码错误,剩余可登录次数:"+(RETRY_LOGIN_MAX_COUNT - retryCount);
|
||||
return Results.error(msg);
|
||||
}
|
||||
//登录成功,清除错误登录次数
|
||||
@@ -156,7 +152,12 @@ public class LoginServiceImpl implements ILoginService {
|
||||
|
||||
}
|
||||
|
||||
private void setRedis(String username, int retryCount) {
|
||||
/**
|
||||
* 登录重试信息存入redis
|
||||
* @param username
|
||||
* @param retryCount
|
||||
*/
|
||||
private void setRetryInfoToRedis(String username, int retryCount) {
|
||||
if( retryCount == 1){
|
||||
redisUtil.set(RETRY_LOGIN_PREFIX + username,retryCount,60L * 15L);
|
||||
}else {
|
||||
@@ -164,14 +165,19 @@ public class LoginServiceImpl implements ILoginService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验用户是否有权限
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
private boolean checkSysPermission(String username) {
|
||||
// 登录成功之后验证是否有权限
|
||||
List<SysPermission> metaList = sysPermissionService.queryByUser(username);
|
||||
if(CollectionUtils.isEmpty(metaList)){
|
||||
return true;
|
||||
}
|
||||
long l = metaList.stream().filter(o-> Objects.equals(o.getMenuType(),0)).count();
|
||||
return l <= 0;
|
||||
long menuSize = metaList.stream().filter(o-> Objects.equals(o.getMenuType(),0)).count();
|
||||
return menuSize <= 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -466,8 +472,8 @@ public class LoginServiceImpl implements ILoginService {
|
||||
RSA rsa = new RSA();
|
||||
String privateKeyBase64 = rsa.getPrivateKeyBase64();
|
||||
String publicKeyBase64 = rsa.getPublicKeyBase64();
|
||||
//存到redis key为公钥 value为私钥
|
||||
redisUtil.set(publicKeyBase64, privateKeyBase64, 180L);
|
||||
//存到redis key为公钥 value为私钥,3分钟
|
||||
redisUtil.set(publicKeyBase64, privateKeyBase64, 10L);
|
||||
Results<String> result = new Results<>();
|
||||
result.setResult(publicKeyBase64);
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user