//只允许一次登录
//获取请求头Authorization+expiresIn
String authorization=exchange.getRequest().getHeaders().getFirst(UaaConstant.AUTHORIZATION);
if(StringUtils.isNotBlank(authorization)){
authorization=authorization.replace("Bearer ","");
}
String expiresIn=exchange.getRequest().getHeaders().getFirst(UaaConstant.EXPIRESIN);
authorization=authorization+expiresIn;
String redisAuth=null;
if(StringUtils.isNotBlank(userName)){
if(ObjectUtil.isNotNull(redisTemplate.opsForValue().get(userName))){
redisAuth=redisTemplate.opsForValue().get(userName).toString();
}
}
if(!authorization.equals(redisAuth)&&StringUtils.isNotBlank(redisAuth)){
return this.errorCom("该账号已在其他地方登录!",exchange,chain);
}
声明:该方法为本人原创,如转载,请申明出处!