代码更新
This commit is contained in:
@@ -118,9 +118,6 @@ public class AuthorizationController {
|
||||
put("user", jsonObject);
|
||||
}};
|
||||
|
||||
// 使redis获取过期的token
|
||||
redisUtils.set("my-satoken", StpUtil.getTokenValue(), StpUtil.getTokenTimeout());
|
||||
|
||||
// 保存在线信息
|
||||
onlineUserService.save(userDto, StpUtil.getTokenValue(), request);
|
||||
return ResponseEntity.ok(authInfo);
|
||||
|
||||
@@ -50,7 +50,6 @@ public class MobileAuthorizationController {
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> login(@Validated @RequestBody AuthUserDto authUser, HttpServletRequest request) throws Exception {
|
||||
// 密码解密 - 前端的加密规则: encrypt(根据实际更改)
|
||||
// String password = authUser.getPassword();
|
||||
String password = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey, authUser.getPassword());
|
||||
// 校验数据库
|
||||
// 根据用户名查询,在比对密码
|
||||
@@ -83,8 +82,6 @@ public class MobileAuthorizationController {
|
||||
put("user", jsonObject);
|
||||
}};
|
||||
|
||||
redisUtils.set("pe-satoken", StpUtil.getTokenValue(), StpUtil.getTokenTimeout());
|
||||
|
||||
return ResponseEntity.ok(authInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
package org.nl.modules.security.satoken;
|
||||
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.modules.common.utils.SecurityUtils;
|
||||
import org.nl.modules.mnt.websocket.MsgType;
|
||||
import org.nl.modules.mnt.websocket.SocketMsg;
|
||||
import org.nl.modules.mnt.websocket.WebSocketServer;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.connection.Message;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
|
||||
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author: lyd
|
||||
* @description: redis过期key监听器
|
||||
* @Date: 2022/10/8
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class TokenKeyExpirationListener extends KeyExpirationEventMessageListener {
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
|
||||
public TokenKeyExpirationListener(RedisMessageListenerContainer listenerContainer) {
|
||||
super(listenerContainer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(Message message, byte[] pattern) {
|
||||
String expireKeyValue = redisTemplate.opsForValue().get("my-satoken");
|
||||
try {
|
||||
if (ObjectUtil.isEmpty(expireKeyValue))
|
||||
WebSocketServer.sendInfo(new SocketMsg("token会话过期!", MsgType.INFO), "exp-token");
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user