diff --git a/backend/src/main/java/io/dataease/auth/config/F2CRealm.java b/backend/src/main/java/io/dataease/auth/config/F2CRealm.java
index 2311e1f449..4dee2a8df7 100644
--- a/backend/src/main/java/io/dataease/auth/config/F2CRealm.java
+++ b/backend/src/main/java/io/dataease/auth/config/F2CRealm.java
@@ -46,6 +46,7 @@ public class F2CRealm extends AuthorizingRealm {
}
//验证登录权限
+
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken auth) throws AuthenticationException {
String token = (String) auth.getCredentials();
@@ -63,7 +64,6 @@ public class F2CRealm extends AuthorizingRealm {
}
String pass = null;
try {
- /*pass = RsaUtil.decryptByPrivateKey(RsaProperties.privateKey, userBean.getPassword());*/
pass = user.getPassword();
} catch (Exception e) {
e.printStackTrace();
diff --git a/backend/src/main/java/io/dataease/auth/util/JWTUtils.java b/backend/src/main/java/io/dataease/auth/util/JWTUtils.java
index 67e27b8752..32b20022a7 100644
--- a/backend/src/main/java/io/dataease/auth/util/JWTUtils.java
+++ b/backend/src/main/java/io/dataease/auth/util/JWTUtils.java
@@ -6,18 +6,20 @@ import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.exceptions.JWTDecodeException;
import com.auth0.jwt.interfaces.DecodedJWT;
import io.dataease.auth.entity.TokenInfo;
+import io.dataease.commons.utils.ServletUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
-
+import javax.servlet.http.HttpServletResponse;
import java.util.Date;
+
public class JWTUtils {
- // token过期时间5分钟 (过期会自动刷新续命 目的是避免一直都是同一个token )
+ // token过期时间5min (过期会自动刷新续命 目的是避免一直都是同一个token )
private static final long EXPIRE_TIME = 1*60*1000;
- // 登录间隔时间 超过这个时间强制重新登录
- private static final long Login_Interval = 2*60*1000;
+ // 登录间隔时间10min 超过这个时间强制重新登录
+ private static final long Login_Interval = 10*60*1000;
/**
@@ -33,7 +35,17 @@ public class JWTUtils {
.withClaim("username", tokenInfo.getUsername())
.withClaim("userId", tokenInfo.getUserId())
.build();
- verifier.verify(token);
+ DecodedJWT jwt = verifier.verify(token);
+ Long lastLoginTime = jwt.getClaim("lastLoginTime").asLong();
+ long now = System.currentTimeMillis();
+ if (now - lastLoginTime > Login_Interval){
+ // 登录超时
+ HttpServletResponse response = ServletUtils.response();
+ response.addHeader("Access-Control-Expose-Headers", "authentication-status");
+ response.setHeader("authentication-status", "login_expire");
+ // 前端拦截 登录超时状态 直接logout
+ return false;
+ }
return true;
}
diff --git a/frontend/src/api/panel/panel.js b/frontend/src/api/panel/panel.js
index ce6a8a33ad..5a91e41b0d 100644
--- a/frontend/src/api/panel/panel.js
+++ b/frontend/src/api/panel/panel.js
@@ -108,4 +108,4 @@ export function post(url, data) {
})
}
-export default { loadTable, getScene, addGroup, delGroup, addTable, delTable, groupTree,defaultTree }
+export default { loadTable, getScene, addGroup, delGroup, addTable, delTable, groupTree, defaultTree }
diff --git a/frontend/src/lang/zh.js b/frontend/src/lang/zh.js
index fa806ca647..b069f30257 100644
--- a/frontend/src/lang/zh.js
+++ b/frontend/src/lang/zh.js
@@ -683,10 +683,10 @@ export default {
},
panel: {
datalist: '视图列表',
- group:'目录',
- panel:'仪表盘',
- groupAdd:'新建目录',
- panelAdd:'新建仪表盘',
+ group: '目录',
+ panel: '仪表盘',
+ groupAdd: '新建目录',
+ panelAdd: '新建仪表盘',
delete: '删除',
move_to: '移动到',
rename: '重命名',
diff --git a/frontend/src/utils/request.js b/frontend/src/utils/request.js
index 05313732a2..2a93f3eab2 100644
--- a/frontend/src/utils/request.js
+++ b/frontend/src/utils/request.js
@@ -52,6 +52,14 @@ const checkAuth = response => {
})
})
}
+ if (response.headers['authentication-status'] === 'login_expire') {
+ const message = this.$t('login.expires')
+ $alert(message, () => {
+ store.dispatch('user/logout').then(() => {
+ location.reload()
+ })
+ })
+ }
// token到期后自动续命 刷新token
if (response.headers[RefreshTokenKey]) {
const refreshToken = response.headers[RefreshTokenKey]
diff --git a/frontend/src/views/panel/index.vue b/frontend/src/views/panel/index.vue
index 6d63ac87c2..25390b55f4 100644
--- a/frontend/src/views/panel/index.vue
+++ b/frontend/src/views/panel/index.vue
@@ -4,65 +4,65 @@
- 列表
-
+ 列表
+
- 收藏
+ 收藏
开发中...
- 分享
+ 分享
开发中...
-
-
-
-
+
+
+
+
-
+