mirror of https://github.com/elunez/eladmin
代码优化
parent
da006624a4
commit
bc5187a7ad
|
@ -4,6 +4,7 @@ import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import me.zhengjie.aop.log.Log;
|
import me.zhengjie.aop.log.Log;
|
||||||
import me.zhengjie.modules.security.service.OnlineUserService;
|
import me.zhengjie.modules.security.service.OnlineUserService;
|
||||||
|
import me.zhengjie.utils.EncryptUtils;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
@ -48,6 +49,8 @@ public class OnlineController {
|
||||||
@PreAuthorize("@el.check()")
|
@PreAuthorize("@el.check()")
|
||||||
public ResponseEntity<Object> delete(@RequestBody Set<String> keys) throws Exception {
|
public ResponseEntity<Object> delete(@RequestBody Set<String> keys) throws Exception {
|
||||||
for (String key : keys) {
|
for (String key : keys) {
|
||||||
|
// 解密Key
|
||||||
|
key = EncryptUtils.desDecrypt(key);
|
||||||
onlineUserService.kickOut(key);
|
onlineUserService.kickOut(key);
|
||||||
}
|
}
|
||||||
return new ResponseEntity<>(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
|
|
|
@ -90,8 +90,8 @@ public class OnlineUserService {
|
||||||
* @param key /
|
* @param key /
|
||||||
* @throws Exception /
|
* @throws Exception /
|
||||||
*/
|
*/
|
||||||
public void kickOut(String key) throws Exception {
|
public void kickOut(String key){
|
||||||
key = properties.getOnlineKey() + EncryptUtils.desDecrypt(key);
|
key = properties.getOnlineKey() + key;
|
||||||
redisUtils.del(key);
|
redisUtils.del(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,9 +148,9 @@ public class OnlineUserService {
|
||||||
try {
|
try {
|
||||||
String token =EncryptUtils.desDecrypt(onlineUser.getKey());
|
String token =EncryptUtils.desDecrypt(onlineUser.getKey());
|
||||||
if(StringUtils.isNotBlank(igoreToken)&&!igoreToken.equals(token)){
|
if(StringUtils.isNotBlank(igoreToken)&&!igoreToken.equals(token)){
|
||||||
this.kickOut(onlineUser.getKey());
|
this.kickOut(token);
|
||||||
}else if(StringUtils.isBlank(igoreToken)){
|
}else if(StringUtils.isBlank(igoreToken)){
|
||||||
this.kickOut(onlineUser.getKey());
|
this.kickOut(token);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("checkUser is error",e);
|
log.error("checkUser is error",e);
|
||||||
|
|
Loading…
Reference in New Issue