diff --git a/framework/gateway/src/main/java/io/metersphere/gateway/service/SSOService.java b/framework/gateway/src/main/java/io/metersphere/gateway/service/SSOService.java index b9f28cb17a..23a492d35a 100644 --- a/framework/gateway/src/main/java/io/metersphere/gateway/service/SSOService.java +++ b/framework/gateway/src/main/java/io/metersphere/gateway/service/SSOService.java @@ -3,6 +3,7 @@ package io.metersphere.gateway.service; import com.fasterxml.jackson.core.type.TypeReference; import io.metersphere.base.domain.AuthSource; import io.metersphere.base.domain.User; +import io.metersphere.commons.constants.UserSource; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.user.SessionUser; import io.metersphere.commons.utils.*; @@ -303,8 +304,8 @@ public class SSOService { user.setSource(authSource.getType()); userLoginService.createOssUser(user); } else { - if (StringUtils.equals(u.getEmail(), email) && !StringUtils.equals(u.getId(), userid)) { - MSException.throwException("email already exists!"); + if (!StringUtils.equals(u.getSource(), UserSource.OAuth2.name())) { + MSException.throwException("user already exist, user source type is " + u.getSource()); } } diff --git a/framework/gateway/src/main/java/io/metersphere/gateway/service/UserLoginService.java b/framework/gateway/src/main/java/io/metersphere/gateway/service/UserLoginService.java index 1dfdd985cc..ed3542ccd5 100644 --- a/framework/gateway/src/main/java/io/metersphere/gateway/service/UserLoginService.java +++ b/framework/gateway/src/main/java/io/metersphere/gateway/service/UserLoginService.java @@ -9,6 +9,7 @@ import io.metersphere.commons.constants.UserStatus; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.user.SessionUser; import io.metersphere.commons.utils.CodingUtil; +import io.metersphere.commons.utils.LogUtil; import io.metersphere.dto.GroupResourceDTO; import io.metersphere.dto.UserDTO; import io.metersphere.dto.UserGroupPermissionDTO; @@ -233,7 +234,9 @@ public class UserLoginService { public UserDTO getLoginUser(String userId, List list) { UserExample example = new UserExample(); example.createCriteria().andIdEqualTo(userId).andSourceIn(list); - if (userMapper.countByExample(example) == 0) { + long count = userMapper.countByExample(example); + if (count == 0) { + LogUtil.error("get login user error, userid is {}, sources is {}", userId, list); return null; } return getUserDTO(userId);