fix(系统设置): OAuth2登录失败
--bug=1019845 --user=李玉号 【系统设置】添加QAuth2成功-选择OAuth2登录-登录失败 https://www.tapd.cn/55049933/s/1298624
This commit is contained in:
parent
87e00fb3d5
commit
e6622291d3
|
@ -3,6 +3,7 @@ package io.metersphere.gateway.service;
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import io.metersphere.base.domain.AuthSource;
|
import io.metersphere.base.domain.AuthSource;
|
||||||
import io.metersphere.base.domain.User;
|
import io.metersphere.base.domain.User;
|
||||||
|
import io.metersphere.commons.constants.UserSource;
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.commons.exception.MSException;
|
||||||
import io.metersphere.commons.user.SessionUser;
|
import io.metersphere.commons.user.SessionUser;
|
||||||
import io.metersphere.commons.utils.*;
|
import io.metersphere.commons.utils.*;
|
||||||
|
@ -303,8 +304,8 @@ public class SSOService {
|
||||||
user.setSource(authSource.getType());
|
user.setSource(authSource.getType());
|
||||||
userLoginService.createOssUser(user);
|
userLoginService.createOssUser(user);
|
||||||
} else {
|
} else {
|
||||||
if (StringUtils.equals(u.getEmail(), email) && !StringUtils.equals(u.getId(), userid)) {
|
if (!StringUtils.equals(u.getSource(), UserSource.OAuth2.name())) {
|
||||||
MSException.throwException("email already exists!");
|
MSException.throwException("user already exist, user source type is " + u.getSource());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import io.metersphere.commons.constants.UserStatus;
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.commons.exception.MSException;
|
||||||
import io.metersphere.commons.user.SessionUser;
|
import io.metersphere.commons.user.SessionUser;
|
||||||
import io.metersphere.commons.utils.CodingUtil;
|
import io.metersphere.commons.utils.CodingUtil;
|
||||||
|
import io.metersphere.commons.utils.LogUtil;
|
||||||
import io.metersphere.dto.GroupResourceDTO;
|
import io.metersphere.dto.GroupResourceDTO;
|
||||||
import io.metersphere.dto.UserDTO;
|
import io.metersphere.dto.UserDTO;
|
||||||
import io.metersphere.dto.UserGroupPermissionDTO;
|
import io.metersphere.dto.UserGroupPermissionDTO;
|
||||||
|
@ -233,7 +234,9 @@ public class UserLoginService {
|
||||||
public UserDTO getLoginUser(String userId, List<String> list) {
|
public UserDTO getLoginUser(String userId, List<String> list) {
|
||||||
UserExample example = new UserExample();
|
UserExample example = new UserExample();
|
||||||
example.createCriteria().andIdEqualTo(userId).andSourceIn(list);
|
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 null;
|
||||||
}
|
}
|
||||||
return getUserDTO(userId);
|
return getUserDTO(userId);
|
||||||
|
|
Loading…
Reference in New Issue