diff --git a/src/main/java/com/yipin/liuwanr/filter/AuthInterceptor.java b/src/main/java/com/yipin/liuwanr/filter/AuthInterceptor.java index 414a255..5f53dca 100644 --- a/src/main/java/com/yipin/liuwanr/filter/AuthInterceptor.java +++ b/src/main/java/com/yipin/liuwanr/filter/AuthInterceptor.java @@ -36,7 +36,11 @@ public class AuthInterceptor implements HandlerInterceptor { ValueOperations ops = stringRedisTemplate.opsForValue(); Object loginStatus = ops.get(token); - + //userid + String userId = request.getParameter("userId"); + if (!StringUtils.isEmpty(userId)){ + return userId.equals(ops.get(token)); + } if( Objects.isNull(loginStatus)){ response.getWriter().print("1");//token错误 diff --git a/src/main/java/com/yipin/liuwanr/service/UserInfoService.java b/src/main/java/com/yipin/liuwanr/service/UserInfoService.java index a98b568..12160c9 100644 --- a/src/main/java/com/yipin/liuwanr/service/UserInfoService.java +++ b/src/main/java/com/yipin/liuwanr/service/UserInfoService.java @@ -441,7 +441,7 @@ public class UserInfoService { //鉴权,登录后将信息存入redis ValueOperations redis = stringRedisTemplate.opsForValue(); String loginToken = UUID.randomUUID().toString(); - redis.set(loginToken,user.getUserName(),2, TimeUnit.HOURS); + redis.set(loginToken,user.getUserId().toString(),2, TimeUnit.HOURS); obj.put("loginToken",loginToken); resp.put("retcode", 200); @@ -553,7 +553,7 @@ public class UserInfoService { //鉴权,登录后将信息存入redis String loginToken = UUID.randomUUID().toString(); - redis.set(loginToken,user.getUserName(),2, TimeUnit.HOURS); + redis.set(loginToken,user.getUserId().toString(),2, TimeUnit.HOURS); user.setLoginToken(loginToken); resp.put("retvalue",user);