update 企业管理员登录
This commit is contained in:
+14
@@ -0,0 +1,14 @@
|
||||
package com.jero.common.constant.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author liJiaRao
|
||||
* @date 2022-08-15 10:27
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum LoginUserTypeEnum {
|
||||
system_, company_management_, company_
|
||||
}
|
||||
+9
@@ -109,6 +109,15 @@ public class ShiroConfig {
|
||||
filterChainDefinitionMap.put("/company/WCLogin", "anon");//微信登录
|
||||
filterChainDefinitionMap.put("/company/jscode2session", "anon");//微信登录凭证校验
|
||||
|
||||
filterChainDefinitionMap.put("/companyManager/login", "anon");//登录接口排除
|
||||
filterChainDefinitionMap.put("/companyManager/smsLogin", "anon");//短信登录接口排除
|
||||
filterChainDefinitionMap.put("/companyManager/logout", "anon");//登出接口排除
|
||||
filterChainDefinitionMap.put("/companyManager/verificationChangePassword", "anon");//短信验证码修改密码
|
||||
filterChainDefinitionMap.put("/companyManager/changePasswordWithToken", "anon");//token修改密码
|
||||
filterChainDefinitionMap.put("/companyManager/sendVerificationCode", "anon");//企业端发送验证码
|
||||
filterChainDefinitionMap.put("/companyManager/WCLogin", "anon");//微信登录
|
||||
filterChainDefinitionMap.put("/companyManager/jscode2session", "anon");//微信登录凭证校验
|
||||
|
||||
|
||||
//和会员系统交互的接口
|
||||
//filterChainDefinitionMap.put("/meeting/payMeeting/addStandards","anon");//会员系统推送会议
|
||||
|
||||
+29
-18
@@ -1,6 +1,7 @@
|
||||
package com.jero.config.shiro;
|
||||
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import com.jero.common.constant.enums.LoginUserTypeEnum;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.authc.AuthenticationException;
|
||||
import org.apache.shiro.authc.AuthenticationInfo;
|
||||
@@ -144,26 +145,36 @@ public class ShiroRealm extends AuthorizingRealm {
|
||||
* @return
|
||||
*/
|
||||
public boolean jwtTokenRefresh(String token, String userName, String passWord) {
|
||||
String cacheToken = String.valueOf(redisUtil.get(CommonConstant.PREFIX_USER_TOKEN + token));
|
||||
if (oConvertUtils.isNotEmpty(cacheToken)) {
|
||||
// 校验token有效性
|
||||
if (!JwtUtil.verify(cacheToken, userName, passWord)) {
|
||||
String newAuthorization = JwtUtil.sign(userName, passWord);
|
||||
// 设置超时时间
|
||||
redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, newAuthorization);
|
||||
redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME *2 / 1000);
|
||||
log.debug("——————————用户在线操作,更新token保证不掉线—————————jwtTokenRefresh——————— "+ token);
|
||||
if (userName.startsWith(LoginUserTypeEnum.company_management_.toString())){
|
||||
String cacheToken = String.valueOf(redisUtil.get(CommonConstant.PREFIX_USER_TOKEN + userName));
|
||||
if (oConvertUtils.isNotEmpty(cacheToken)) {
|
||||
// 校验token有效性
|
||||
if (!JwtUtil.verify(cacheToken, userName, passWord)) {
|
||||
//String newAuthorization = JwtUtil.sign(userName, passWord);
|
||||
// 设置超时时间
|
||||
//redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, newAuthorization);
|
||||
redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + userName, JwtUtil.EXPIRE_TIME *2 / 1000);
|
||||
|
||||
log.debug("——————————用户在线操作,更新token保证不掉线—————————jwtTokenRefresh——————— "+ token);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//update-begin--Author:scott Date:20191005 for:解决每次请求,都重写redis中 token缓存问题
|
||||
// else {
|
||||
// // 设置超时时间
|
||||
// redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, cacheToken);
|
||||
// redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME / 1000);
|
||||
// }
|
||||
//update-end--Author:scott Date:20191005 for:解决每次请求,都重写redis中 token缓存问题
|
||||
return true;
|
||||
return false;
|
||||
}else{
|
||||
String cacheToken = String.valueOf(redisUtil.get(CommonConstant.PREFIX_USER_TOKEN + token));
|
||||
if (oConvertUtils.isNotEmpty(cacheToken)) {
|
||||
// 校验token有效性
|
||||
if (!JwtUtil.verify(cacheToken, userName, passWord)) {
|
||||
//String newAuthorization = JwtUtil.sign(userName, passWord);
|
||||
// 设置超时时间
|
||||
//redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, newAuthorization);
|
||||
redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME *2 / 1000);
|
||||
log.debug("——————————用户在线操作,更新token保证不掉线—————————jwtTokenRefresh——————— "+ token);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user