Skip to content

Commit

Permalink
fix satoken interceptor
Browse files Browse the repository at this point in the history
  • Loading branch information
naah69 committed Oct 12, 2022
1 parent 0e97bb8 commit dcfffe7
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.Objects;

import javax.interceptor.InvocationContext;

import cn.dev33.satoken.annotation.SaIgnore;
import cn.dev33.satoken.exception.BackResultException;
import cn.dev33.satoken.exception.StopMatchException;
import cn.dev33.satoken.fun.SaParamFunction;
import cn.dev33.satoken.strategy.SaStrategy;

/**
Expand All @@ -21,24 +19,6 @@

public class AbstractSaInterceptor<T extends Annotation> {

/**
* 认证函数:每次请求执行
* <p>
* 参数:路由处理函数指针
*/
public static SaParamFunction<Object> auth = handler -> {
};

/**
* 写入[认证函数]: 每次请求执行
*
* @param auth /
* @return 对象自身
*/
public static void setAuth(SaParamFunction<Object> auth) {
AbstractSaInterceptor.auth = auth;
}

public Object interceptAnnotation(InvocationContext context) throws Exception {

try {
Expand All @@ -50,11 +30,6 @@ public Object interceptAnnotation(InvocationContext context) throws Exception {
}
// 注解校验
SaStrategy.me.checkMethodAnnotation.accept(method);
if (Objects.nonNull(auth)) {
// Auth 校验
auth.run(context);
}

} catch (StopMatchException e) {
// 停止匹配,进入Controller
} catch (BackResultException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import javax.interceptor.InvocationContext;

import cn.dev33.satoken.annotation.SaCheckBasic;
import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.util.SaTokenConsts;
import io.quarkus.arc.Priority;

Expand All @@ -18,7 +17,7 @@
@SaCheckBasic
@Interceptor
@Priority(SaTokenConsts.ASSEMBLY_ORDER)
public class SaCheckBasicInterceptor extends AbstractSaInterceptor<SaCheckLogin> {
public class SaCheckBasicInterceptor extends AbstractSaInterceptor<SaCheckBasic> {

@AroundInvoke
public Object intercept(InvocationContext context) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import javax.interceptor.InvocationContext;

import cn.dev33.satoken.annotation.SaCheckDisable;
import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.util.SaTokenConsts;
import io.quarkus.arc.Priority;

Expand All @@ -18,7 +17,7 @@
@SaCheckDisable
@Interceptor
@Priority(SaTokenConsts.ASSEMBLY_ORDER)
public class SaCheckDisableInterceptor extends AbstractSaInterceptor<SaCheckLogin> {
public class SaCheckDisableInterceptor extends AbstractSaInterceptor<SaCheckDisable> {

@AroundInvoke
public Object intercept(InvocationContext context) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import javax.interceptor.Interceptor;
import javax.interceptor.InvocationContext;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.util.SaTokenConsts;
import io.quarkus.arc.Priority;
Expand All @@ -18,7 +17,7 @@
@SaCheckPermission
@Interceptor
@Priority(SaTokenConsts.ASSEMBLY_ORDER)
public class SaCheckPermissionInterceptor extends AbstractSaInterceptor<SaCheckLogin> {
public class SaCheckPermissionInterceptor extends AbstractSaInterceptor<SaCheckPermission> {

@AroundInvoke
public Object intercept(InvocationContext context) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import javax.interceptor.Interceptor;
import javax.interceptor.InvocationContext;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaCheckRole;
import cn.dev33.satoken.util.SaTokenConsts;
import io.quarkus.arc.Priority;
Expand All @@ -18,7 +17,7 @@
@SaCheckRole
@Interceptor
@Priority(SaTokenConsts.ASSEMBLY_ORDER)
public class SaCheckRoleInterceptor extends AbstractSaInterceptor<SaCheckLogin> {
public class SaCheckRoleInterceptor extends AbstractSaInterceptor<SaCheckRole> {

@AroundInvoke
public Object intercept(InvocationContext context) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import javax.interceptor.Interceptor;
import javax.interceptor.InvocationContext;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaCheckSafe;
import cn.dev33.satoken.util.SaTokenConsts;
import io.quarkus.arc.Priority;
Expand All @@ -18,7 +17,7 @@
@SaCheckSafe
@Interceptor
@Priority(SaTokenConsts.ASSEMBLY_ORDER)
public class SaCheckSafeInterceptor extends AbstractSaInterceptor<SaCheckLogin> {
public class SaCheckSafeInterceptor extends AbstractSaInterceptor<SaCheckSafe> {

@AroundInvoke
public Object intercept(InvocationContext context) throws Exception {
Expand Down

0 comments on commit dcfffe7

Please sign in to comment.