diff --git a/epmet-auth/src/main/java/com/epmet/constant/SsoConstant.java b/epmet-auth/src/main/java/com/epmet/constant/SsoConstant.java index b3b86fd45d..88b4f56389 100644 --- a/epmet-auth/src/main/java/com/epmet/constant/SsoConstant.java +++ b/epmet-auth/src/main/java/com/epmet/constant/SsoConstant.java @@ -15,4 +15,7 @@ public interface SsoConstant { String INSERT_UPDATE_USER_FAILURE = "新增或更新user_weChat失败......"; + String USER_ID_IS_NULL = "userId为空,生成token失败......"; + String CUSTOMER_ID_IS_NULL = "customerId为空,缓存放置token失败......"; + } diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java index 3872ae1faf..bafae81684 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java @@ -22,6 +22,7 @@ import com.epmet.jwt.JwtTokenUtils; import com.epmet.redis.SsoRedis; import com.epmet.service.SsoService; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -79,10 +80,17 @@ public class SsoServiceImpl implements SsoService { } userId = userDTOResult.getData().getId(); } + if (StringUtils.isBlank(userId)){ + throw new RenException(SsoConstant.USER_ID_IS_NULL); + } //生成业务token String token = this.generateToken(formDTO.getApp(),formDTO.getClient(), userId); //存放Redis - this.disposeTokenDto(formDTO, userId, token, getCustomerId(formDTO.getAppId())); + String customerId = getCustomerId(formDTO.getAppId()); + if (StringUtils.isBlank(customerId)){ + throw new RenException(SsoConstant.CUSTOMER_ID_IS_NULL); + } + this.disposeTokenDto(formDTO, userId, token, customerId); return new SsoLoginResultDTO(token); }