From 076b2a90d0ddd75e4e27d3813b6143abbca25597 Mon Sep 17 00:00:00 2001
From: liukangdong <898885815@qq.com>
Date: 星期三, 24 七月 2024 17:40:09 +0800
Subject: [PATCH] Merge branch 'master' of http://139.186.142.91:10010/r/productDev/zbomyoujia
---
server/service/src/main/java/com/doumee/config/Jwt/WebMvcConfig.java | 34 +++++++++++++++-------------------
1 files changed, 15 insertions(+), 19 deletions(-)
diff --git a/server/service/src/main/java/com/doumee/config/Jwt/WebMvcConfig.java b/server/service/src/main/java/com/doumee/config/Jwt/WebMvcConfig.java
index f7d6ad6..7cc5155 100644
--- a/server/service/src/main/java/com/doumee/config/Jwt/WebMvcConfig.java
+++ b/server/service/src/main/java/com/doumee/config/Jwt/WebMvcConfig.java
@@ -66,30 +66,19 @@
Class<?> beanType = handlerMethod.getBeanType();
Boolean checkFlag = false;
- if(!(
- beanType.isAnnotationPresent(LoginRequired.class) || handlerMethod.hasMethodAnnotation(LoginRequired.class)
- || beanType.isAnnotationPresent(UserLoginRequired.class) || handlerMethod.hasMethodAnnotation(UserLoginRequired.class))
+ if(!( handlerMethod.hasMethodAnnotation(LoginRequired.class) || handlerMethod.hasMethodAnnotation(UserLoginRequired.class))
){
return true;
}
- // 鏈� @LoginRequired 娉ㄨВ锛岄渶瑕佺櫥褰曡璇� 瀹㈡埛绔娇鐢�
- if (!checkFlag && (beanType.isAnnotationPresent(LoginRequired.class) || handlerMethod.hasMethodAnnotation(LoginRequired.class))) {
- String token = request.getHeader(JwtTokenUtil.HEADER_KEY);
- if(StringUtils.isBlank(token)){
- throw new BusinessException(ResponseStatus.NO_LOGIN.getCode(),"鏈櫥褰�");
- }
- if (StringUtils.isNotBlank(token)) {
- checkFlag = checkLogin(request,response,token);
- }
+ String token = request.getHeader(JwtTokenUtil.HEADER_KEY);
+ if(StringUtils.isBlank(token)){
+ throw new BusinessException(ResponseStatus.NO_LOGIN.getCode(),"鏈櫥褰�");
}
- if(!checkFlag && (beanType.isAnnotationPresent(UserLoginRequired.class) || handlerMethod.hasMethodAnnotation(UserLoginRequired.class))){
- String token = request.getHeader(JwtTokenUtil.HEADER_KEY);
- if(StringUtils.isBlank(token)){
- throw new BusinessException(ResponseStatus.NO_LOGIN.getCode(),"鏈櫥褰�");
- }
- if (StringUtils.isNotBlank(token)) {
+ if (handlerMethod.hasMethodAnnotation(LoginRequired.class)) {
+ checkFlag = checkLogin(request,response,token);
+ }
+ if(!checkFlag && handlerMethod.hasMethodAnnotation(UserLoginRequired.class)){
checkFlag = checkPersonnelLogin(request,response,token);
- }
}
if(!checkFlag){
throw new BusinessException(ResponseStatus.NO_LOGIN.getCode(),"鏈櫥褰�");
@@ -112,6 +101,9 @@
if(Objects.isNull(member)){
throw new BusinessException(ResponseStatus.DATA_EMPTY);
}
+ if(Objects.isNull(member.getOpenid())){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鐢ㄦ埛宸叉敞閿�,璇烽噸鏂扮櫥褰�");
+ }
if(Constants.equalsInteger(member.getIsdeleted(),Constants.ONE)){
throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鐢ㄦ埛宸插垹闄�,璇疯仈绯荤鐞嗗憳");
}
@@ -120,6 +112,8 @@
}
request.setAttribute(JwtTokenUtil.UserId_Name, memberId);
request.setAttribute(JwtTokenUtil.UserType, ZTConstants.CUSTOMER);
+ request.setAttribute(JwtTokenUtil.HEADER_KEY, ZTConstants.CUSTOMER+"_"+token);
+ request.setAttribute(JwtTokenUtil.UserInfo, tokenRedis);
return true;
} catch (IllegalArgumentException | JwtException e) {
throw new BusinessException(ResponseStatus.NO_LOGIN.getCode(),"鏈櫥褰�");
@@ -145,6 +139,8 @@
}
request.setAttribute(JwtTokenUtil.UserId_Name, userId);
request.setAttribute(JwtTokenUtil.UserType, ZTConstants.BUSINESS);
+ request.setAttribute(JwtTokenUtil.HEADER_KEY, ZTConstants.CUSTOMER+"_"+token);
+ request.setAttribute(JwtTokenUtil.UserInfo, tokenRedis);
return true;
} catch (IllegalArgumentException | JwtException e) {
throw new BusinessException(ResponseStatus.NO_LOGIN.getCode(),"鏈櫥褰�");
--
Gitblit v1.9.3