mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-09-24 07:19:46 +08:00
update 同步 dev 分支 更新最新改动
This commit is contained in:
@ -4,7 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.http.HttpStatus;
|
||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
@ -76,14 +76,14 @@ public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler {
|
||||
* 获取登录用户名
|
||||
*/
|
||||
private String getLoginUsername() {
|
||||
LoginUser loginUser;
|
||||
SysUser user;
|
||||
try {
|
||||
loginUser = SecurityUtils.getLoginUser();
|
||||
user = SecurityUtils.getUser();
|
||||
} catch (Exception e) {
|
||||
log.warn("自动注入警告 => 用户未登录");
|
||||
return null;
|
||||
}
|
||||
return loginUser.getUsername();
|
||||
return user.getUserName();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import com.ruoyi.common.exception.DemoModeException;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
@ -42,8 +41,7 @@ public class GlobalExceptionHandler {
|
||||
* 角色校验异常
|
||||
*/
|
||||
@ExceptionHandler(NotRoleException.class)
|
||||
public AjaxResult handleAccessDeniedException(NotRoleException e, HttpServletRequest request)
|
||||
{
|
||||
public AjaxResult<Void> handleAccessDeniedException(NotRoleException e, HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',角色校验失败'{}'", requestURI, e.getMessage());
|
||||
return AjaxResult.error(HttpStatus.HTTP_FORBIDDEN, "没有角色,请联系管理员授权");
|
||||
@ -53,11 +51,10 @@ public class GlobalExceptionHandler {
|
||||
* 认证失败
|
||||
*/
|
||||
@ExceptionHandler(NotLoginException.class)
|
||||
public AjaxResult handleAccessDeniedException(NotLoginException e, HttpServletRequest request)
|
||||
{
|
||||
public AjaxResult<Void> handleAccessDeniedException(NotLoginException e, HttpServletRequest request) {
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求访问:{},认证失败,无法访问系统资源", requestURI, e.getMessage());
|
||||
return AjaxResult.error(HttpStatus.HTTP_UNAUTHORIZED, StringUtils.format("请求访问:{},认证失败,无法访问系统资源", requestURI));
|
||||
log.error("请求地址'{}',认证失败'{}',无法访问系统资源", requestURI, e.getMessage());
|
||||
return AjaxResult.error(HttpStatus.HTTP_UNAUTHORIZED, StringUtils.format("请求地址'{}',认证失败'{}',无法访问系统资源", requestURI));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user