Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
单灵石
jeecg-boot
提交
89f4d122
J
jeecg-boot
项目概览
单灵石
/
jeecg-boot
与 Fork 源项目一致
Fork自
jeecg / jeecg-boot
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jeecg-boot
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
89f4d122
编写于
10月 12, 2020
作者:
JEECG低代码平台
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
在线切换部门,用户缓存信息更新 issues/I1X4DT
上级
b92bec3e
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
2 addition
and
47 deletion
+2
-47
jeecg-boot/jeecg-boot-base-common/src/main/java/org/jeecg/common/constant/CacheConstant.java
...rc/main/java/org/jeecg/common/constant/CacheConstant.java
+0
-5
jeecg-boot/jeecg-boot-base-common/src/main/java/org/jeecg/config/shiro/ShiroRealm.java
...mmon/src/main/java/org/jeecg/config/shiro/ShiroRealm.java
+1
-8
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/cas/controller/CasClientController.java
...org/jeecg/modules/cas/controller/CasClientController.java
+0
-8
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/LoginController.java
.../org/jeecg/modules/system/controller/LoginController.java
+1
-18
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/ThirdLoginController.java
...jeecg/modules/system/controller/ThirdLoginController.java
+0
-8
未找到文件。
jeecg-boot/jeecg-boot-base-common/src/main/java/org/jeecg/common/constant/CacheConstant.java
浏览文件 @
89f4d122
...
...
@@ -7,11 +7,6 @@ package org.jeecg.common.constant;
*/
public
interface
CacheConstant
{
/**
* 缓存用户jwt
*/
public
static
final
String
SYS_USERS_CACHE_JWT
=
"sys:cache:user:jwt"
;
/**
* 字典信息缓存
*/
...
...
jeecg-boot/jeecg-boot-base-common/src/main/java/org/jeecg/config/shiro/ShiroRealm.java
浏览文件 @
89f4d122
...
...
@@ -114,14 +114,7 @@ public class ShiroRealm extends AuthorizingRealm {
// 查询用户信息
log
.
debug
(
"———校验token是否有效————checkUserTokenIsEffect——————— "
+
token
);
LoginUser
loginUser
=
(
LoginUser
)
redisUtil
.
get
(
CacheConstant
.
SYS_USERS_CACHE_JWT
+
":"
+
token
);
//TODO 当前写法导致两个小时操作中token过期
//如果redis缓存用户信息为空,则通过接口获取用户信息,避免超过两个小时操作中token过期
if
(
loginUser
==
null
){
loginUser
=
commonAPI
.
getUserByName
(
username
);
//密码二次加密,因为存于redis会泄露
loginUser
.
setPassword
(
SecureUtil
.
md5
(
loginUser
.
getPassword
()));
}
LoginUser
loginUser
=
commonAPI
.
getUserByName
(
username
);
if
(
loginUser
==
null
)
{
throw
new
AuthenticationException
(
"用户不存在!"
);
}
...
...
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/cas/controller/CasClientController.java
浏览文件 @
89f4d122
...
...
@@ -87,14 +87,6 @@ public class CasClientController {
redisUtil
.
set
(
CommonConstant
.
PREFIX_USER_TOKEN
+
token
,
token
);
redisUtil
.
expire
(
CommonConstant
.
PREFIX_USER_TOKEN
+
token
,
JwtUtil
.
EXPIRE_TIME
*
2
/
1000
);
//update-begin-author:taoyan date:20200812 for:登录缓存用户信息
LoginUser
vo
=
new
LoginUser
();
BeanUtils
.
copyProperties
(
sysUser
,
vo
);
vo
.
setPassword
(
SecureUtil
.
md5
(
sysUser
.
getPassword
()));
redisUtil
.
set
(
CacheConstant
.
SYS_USERS_CACHE_JWT
+
":"
+
token
,
vo
);
redisUtil
.
expire
(
CacheConstant
.
SYS_USERS_CACHE_JWT
+
":"
+
token
,
JwtUtil
.
EXPIRE_TIME
*
2
/
1000
);
//update-end-author:taoyan date:20200812 for:登录缓存用户信息
//获取用户部门信息
JSONObject
obj
=
new
JSONObject
();
List
<
SysDepart
>
departs
=
sysDepartService
.
queryUserDeparts
(
sysUser
.
getId
());
...
...
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/LoginController.java
浏览文件 @
89f4d122
...
...
@@ -356,20 +356,11 @@ public class LoginController {
String
syspassword
=
sysUser
.
getPassword
();
String
username
=
sysUser
.
getUsername
();
// 生成token
String
token
=
JwtUtil
.
sign
(
username
,
SecureUtil
.
md5
(
syspassword
)
);
String
token
=
JwtUtil
.
sign
(
username
,
syspassword
);
// 设置token缓存有效时间
redisUtil
.
set
(
CommonConstant
.
PREFIX_USER_TOKEN
+
token
,
token
);
redisUtil
.
expire
(
CommonConstant
.
PREFIX_USER_TOKEN
+
token
,
JwtUtil
.
EXPIRE_TIME
*
2
/
1000
);
//update-begin-author:taoyan date:20200812 for:登录缓存用户信息
LoginUser
vo
=
new
LoginUser
();
BeanUtils
.
copyProperties
(
sysUser
,
vo
);
//密码二次加密,因为存于redis会泄露
vo
.
setPassword
(
SecureUtil
.
md5
(
sysUser
.
getPassword
()));
redisUtil
.
set
(
CacheConstant
.
SYS_USERS_CACHE_JWT
+
":"
+
token
,
vo
);
redisUtil
.
expire
(
CacheConstant
.
SYS_USERS_CACHE_JWT
+
":"
+
token
,
JwtUtil
.
EXPIRE_TIME
*
2
/
1000
);
//update-end-author:taoyan date:20200812 for:登录缓存用户信息
// 获取用户部门信息
JSONObject
obj
=
new
JSONObject
();
List
<
SysDepart
>
departs
=
sysDepartService
.
queryUserDeparts
(
sysUser
.
getId
());
...
...
@@ -484,14 +475,6 @@ public class LoginController {
redisUtil
.
set
(
CommonConstant
.
PREFIX_USER_TOKEN
+
token
,
token
);
redisUtil
.
expire
(
CommonConstant
.
PREFIX_USER_TOKEN
+
token
,
JwtUtil
.
EXPIRE_TIME
*
2
/
1000
);
//update-begin-author:taoyan date:20200812 for:登录缓存用户信息
LoginUser
vo
=
new
LoginUser
();
BeanUtils
.
copyProperties
(
sysUser
,
vo
);
vo
.
setPassword
(
SecureUtil
.
md5
(
sysUser
.
getPassword
()));
redisUtil
.
set
(
CacheConstant
.
SYS_USERS_CACHE_JWT
+
":"
+
token
,
vo
);
redisUtil
.
expire
(
CacheConstant
.
SYS_USERS_CACHE_JWT
+
":"
+
token
,
JwtUtil
.
EXPIRE_TIME
*
2
/
1000
);
//update-end-author:taoyan date:20200812 for:登录缓存用户信息
//token 信息
obj
.
put
(
"token"
,
token
);
result
.
setResult
(
obj
);
...
...
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/ThirdLoginController.java
浏览文件 @
89f4d122
...
...
@@ -109,14 +109,6 @@ public class ThirdLoginController {
// 设置超时时间
redisUtil
.
expire
(
CommonConstant
.
PREFIX_USER_TOKEN
+
token
,
JwtUtil
.
EXPIRE_TIME
/
1000
);
//update-begin-author:taoyan date:20200812 for:登录缓存用户信息
LoginUser
redisUser
=
new
LoginUser
();
BeanUtils
.
copyProperties
(
user
,
redisUser
);
redisUser
.
setPassword
(
SecureUtil
.
md5
(
user
.
getPassword
()));
redisUtil
.
set
(
CacheConstant
.
SYS_USERS_CACHE_JWT
+
":"
+
token
,
redisUser
);
redisUtil
.
expire
(
CacheConstant
.
SYS_USERS_CACHE_JWT
+
":"
+
token
,
JwtUtil
.
EXPIRE_TIME
*
2
/
1000
);
//update-end-author:taoyan date:20200812 for:登录缓存用户信息
modelMap
.
addAttribute
(
"token"
,
token
);
//update-begin--Author:wangshuai Date:20200729 for:接口在签名校验失败时返回失败的标识码 issues#1441--------------------
}
else
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录