|
@@ -1,11 +1,6 @@
|
|
|
package cn.reghao.dfs.store.aop;
|
|
package cn.reghao.dfs.store.aop;
|
|
|
|
|
|
|
|
import cn.reghao.dfs.store.util.UserContext;
|
|
import cn.reghao.dfs.store.util.UserContext;
|
|
|
-import cn.reghao.jutil.web.ServletUtil;
|
|
|
|
|
-import cn.reghao.tnb.account.api.constant.TokenType;
|
|
|
|
|
-import cn.reghao.tnb.account.api.dto.AccountInfo;
|
|
|
|
|
-import cn.reghao.tnb.account.api.iface.AuthService;
|
|
|
|
|
-import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
|
|
import org.aspectj.lang.ProceedingJoinPoint;
|
|
import org.aspectj.lang.ProceedingJoinPoint;
|
|
|
import org.aspectj.lang.annotation.Around;
|
|
import org.aspectj.lang.annotation.Around;
|
|
|
import org.aspectj.lang.annotation.Aspect;
|
|
import org.aspectj.lang.annotation.Aspect;
|
|
@@ -22,10 +17,6 @@ import java.lang.reflect.Method;
|
|
|
@Component
|
|
@Component
|
|
|
@Aspect
|
|
@Aspect
|
|
|
public class AuthUserAspect {
|
|
public class AuthUserAspect {
|
|
|
- @DubboReference(check = false)
|
|
|
|
|
- private AuthService authService;
|
|
|
|
|
- private final String cookieKey = "USERDATA";
|
|
|
|
|
-
|
|
|
|
|
@Pointcut("@annotation(cn.reghao.dfs.store.aop.AuthUser)")
|
|
@Pointcut("@annotation(cn.reghao.dfs.store.aop.AuthUser)")
|
|
|
public void loginPointCut(){
|
|
public void loginPointCut(){
|
|
|
}
|
|
}
|
|
@@ -36,21 +27,9 @@ public class AuthUserAspect {
|
|
|
MethodSignature ms = (MethodSignature)point.getSignature();
|
|
MethodSignature ms = (MethodSignature)point.getSignature();
|
|
|
Method method = aClass.getDeclaredMethod(ms.getName(),ms.getParameterTypes());
|
|
Method method = aClass.getDeclaredMethod(ms.getName(),ms.getParameterTypes());
|
|
|
AuthUser authUser = method.getAnnotation(AuthUser.class);
|
|
AuthUser authUser = method.getAnnotation(AuthUser.class);
|
|
|
-
|
|
|
|
|
- String sessId = ServletUtil.getCookie(cookieKey);
|
|
|
|
|
- AccountInfo accountInfo = null;
|
|
|
|
|
- if (sessId != null) {
|
|
|
|
|
- accountInfo = authService.getAccountInfo(TokenType.cookie.getValue(), sessId);
|
|
|
|
|
- } else {
|
|
|
|
|
- sessId = ServletUtil.getBearerToken();
|
|
|
|
|
- if (sessId != null) {
|
|
|
|
|
- accountInfo = authService.getAccountInfo(TokenType.token.getValue(), sessId);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ long userId = UserContext.getUser();
|
|
|
boolean auth = authUser.value();
|
|
boolean auth = authUser.value();
|
|
|
- if (auth && accountInfo != null) {
|
|
|
|
|
- UserContext userContext = new UserContext(accountInfo.getUserId());
|
|
|
|
|
|
|
+ if (auth && userId != -1) {
|
|
|
return point.proceed(point.getArgs());
|
|
return point.proceed(point.getArgs());
|
|
|
}
|
|
}
|
|
|
|
|
|