add
This commit is contained in:
@ -0,0 +1,31 @@
|
||||
package com.qiaoba.auth.advice;
|
||||
|
||||
|
||||
import com.qiaoba.common.base.result.AjaxResult;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
/**
|
||||
* 全局异常处理
|
||||
*
|
||||
* @author ailanyin
|
||||
* @version 1.0
|
||||
* @since 2021/10/15 0015 下午 16:43
|
||||
*/
|
||||
@ControllerAdvice
|
||||
public class SecurityExceptionAdvice {
|
||||
|
||||
/**
|
||||
* 无权限异常
|
||||
*
|
||||
* @param e AccessDeniedException
|
||||
* @return AjaxResult
|
||||
*/
|
||||
@ExceptionHandler({AccessDeniedException.class})
|
||||
@ResponseBody
|
||||
public AjaxResult handlerAccessDeniedException(AccessDeniedException e) {
|
||||
return AjaxResult.error("此接口无权限访问");
|
||||
}
|
||||
}
|
@ -3,4 +3,5 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
com.qiaoba.auth.handler.AccessDeniedHandler,\
|
||||
com.qiaoba.auth.handler.LogoutHandler,\
|
||||
com.qiaoba.auth.filters.JwtAuthenticationTokenFilter,\
|
||||
com.qiaoba.auth.advice.SecurityExceptionAdvice,\
|
||||
com.qiaoba.auth.config.SpringSecurityConfig
|
||||
|
Reference in New Issue
Block a user