去除用户token的认证
This commit is contained in:
@ -6,6 +6,7 @@ import java.util.Objects;
|
|||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.BeansException;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@ -31,13 +32,16 @@ public class BaseCacheUserServiceImpl implements IBaseCacheUserService {
|
|||||||
@Override
|
@Override
|
||||||
public BaseCacheUser getCacheUser() {
|
public BaseCacheUser getCacheUser() {
|
||||||
BaseCacheUser buser = new BaseCacheUser();
|
BaseCacheUser buser = new BaseCacheUser();
|
||||||
BeanUtils.copyProperties(SecurityContextHolder.getContext().getAuthentication().getPrincipal(), buser);
|
try {
|
||||||
|
BeanUtils.copyProperties(SecurityContextHolder.getContext().getAuthentication().getPrincipal(), buser);
|
||||||
|
|
||||||
if (Objects.isNull(buser.getUserId())) {
|
// if (Objects.isNull(buser.getUserId())) {
|
||||||
throw new InvalidTokenException("用户验证失败,无效的token!");
|
// throw new InvalidTokenException("用户验证失败,无效的token!");
|
||||||
|
// }
|
||||||
|
log.debug("Current user principal: " + buser);
|
||||||
|
} catch (BeansException e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
}
|
}
|
||||||
log.debug("Current user principal: " + buser);
|
|
||||||
|
|
||||||
return buser;
|
return buser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user