From 93fe0b66e85e95e3a7e77a28504d6d289b6906b9 Mon Sep 17 00:00:00 2001 From: kaiyu <404897439@qq.com> Date: Fri, 08 Oct 2021 13:11:22 +0800 Subject: [PATCH] screen-manage screen-api 更改拦截器逻辑,记录token无效的请求IP以及URL。 manage记录到数据库日志中 api记录在日志文件中 --- screen-common/src/main/java/com/moral/util/TokenUtils.java | 16 ++++++++++++---- 1 files changed, 12 insertions(+), 4 deletions(-) diff --git a/screen-common/src/main/java/com/moral/util/TokenUtils.java b/screen-common/src/main/java/com/moral/util/TokenUtils.java index 16f19ad..d82f09e 100644 --- a/screen-common/src/main/java/com/moral/util/TokenUtils.java +++ b/screen-common/src/main/java/com/moral/util/TokenUtils.java @@ -85,7 +85,7 @@ * @Author: ��������� * @Date: 2021/3/10 */ - public static void checkToken(String token) { + public static boolean checkToken(String token) { try { String[] tokenArray = TokenEncryptUtils.decoded(token).split("/"); //������token������������ @@ -99,9 +99,9 @@ ResponseCodeEnum.TOKEN_INVALID.getMsg()); } } catch (Exception e) { - throw new TokenException(ResponseCodeEnum.TOKEN_INVALID.getCode(), - ResponseCodeEnum.TOKEN_INVALID.getMsg()); + return false; } + return true; } @@ -120,6 +120,11 @@ return userInfo; } + public static Object getUserInfo() { + String token = getCurrentToken(); + return getUserInfoByToken(token); + } + /** * @Description: ������token * @Param: [uid, token] @@ -128,6 +133,8 @@ * @Date: 2021/3/11 */ public static void destoryToken(String uid, String token) { + if(ObjectUtils.isEmpty(uid)||ObjectUtils.isEmpty(token)) + return; redisTemplate.delete(token); redisTemplate.opsForHash().delete("user_token", uid); } @@ -144,6 +151,7 @@ destoryToken(getUidByToken(token), token); } + /** * @Description: ���������������������token * @Param: [] @@ -157,7 +165,7 @@ public static void destoryToken(Integer id) { String token = getTokenById(id); - destoryToken(token,String.valueOf(id)); + destoryToken(String.valueOf(id),token); } /** -- Gitblit v1.8.0