From 75223b9f64654110873e7f2328457f2e34830cce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9C=E7=8E=89=E7=90=A6?= <7507756+jiang_yuqi@user.noreply.gitee.com> Date: Tue, 22 Aug 2023 23:53:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/ruoyi/framework/aspectj/LogAspect.java | 8 ++++++++ .../java/com/ruoyi/framework/config/SecurityConfig.java | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java index a69b82bc..381992a6 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java @@ -2,6 +2,7 @@ package com.ruoyi.framework.aspectj; import java.util.Collection; import java.util.Map; +import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang3.ArrayUtils; @@ -100,6 +101,13 @@ public class LogAspect if (loginUser != null) { operLog.setOperName(loginUser.getUsername()); + /*********************getAuthentication未获取用户信息时,从cookies中获取操作人信息***************************/ + }else if(ServletUtils.getRequest().getCookies()!=null && ServletUtils.getRequest().getCookies().length>0){ + for(Cookie cookie:ServletUtils.getRequest().getCookies()){ + if(cookie.getName().equals("username")){ + operLog.setOperName(cookie.getValue()); + } + } } if (e != null) diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java index 436a6df5..60152ad0 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java @@ -111,7 +111,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter // 过滤请求 .authorizeRequests() // 对于登录login 注册register 验证码captchaImage 允许匿名访问 - .antMatchers("/login","/wechatLogin/**", "/register", "/captchaImage", "/weixin/**","/bgscreen/**","/publics/**","/system/dict/data/**").permitAll() + .antMatchers("/login","/wechatLogin/**", "/common/**", "/register", "/captchaImage", "/weixin/**","/bgscreen/**","/publics/**","/system/dict/data/**").permitAll() // 静态资源,可匿名访问 .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/**/img/**", "/profile/**").permitAll() .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()