master
yangjie 4 years ago
parent 2e5870e001
commit a496c7b643
  1. 6
      src/main/java/com/yipin/liuwanr/filter/AuthInterceptor.java
  2. 4
      src/main/java/com/yipin/liuwanr/service/UserInfoService.java

@ -36,7 +36,11 @@ public class AuthInterceptor implements HandlerInterceptor {
ValueOperations<String, String> ops = stringRedisTemplate.opsForValue(); ValueOperations<String, String> ops = stringRedisTemplate.opsForValue();
Object loginStatus = ops.get(token); 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)){ if( Objects.isNull(loginStatus)){
response.getWriter().print("1");//token错误 response.getWriter().print("1");//token错误

@ -441,7 +441,7 @@ public class UserInfoService {
//鉴权,登录后将信息存入redis //鉴权,登录后将信息存入redis
ValueOperations<String, String> redis = stringRedisTemplate.opsForValue(); ValueOperations<String, String> redis = stringRedisTemplate.opsForValue();
String loginToken = UUID.randomUUID().toString(); 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); obj.put("loginToken",loginToken);
resp.put("retcode", 200); resp.put("retcode", 200);
@ -553,7 +553,7 @@ public class UserInfoService {
//鉴权,登录后将信息存入redis //鉴权,登录后将信息存入redis
String loginToken = UUID.randomUUID().toString(); 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); user.setLoginToken(loginToken);
resp.put("retvalue",user); resp.put("retvalue",user);

Loading…
Cancel
Save