提交 a2c4ab11 编写于 作者: sq3536's avatar sq3536

userauth 改动

上级 0ec4a9d2
...@@ -61,8 +61,14 @@ public class UserDingtalkRegisterService { ...@@ -61,8 +61,14 @@ public class UserDingtalkRegisterService {
if((sysOpenAccess==null|| (sysOpenAccess.getDisabled()!=null && sysOpenAccess.getDisabled()==1))&&throwEx) if((sysOpenAccess==null|| (sysOpenAccess.getDisabled()!=null && sysOpenAccess.getDisabled()==1))&&throwEx)
throw new BadRequestAlertException("获取接入配置失败","UserDingtalkRegisterService",""); throw new BadRequestAlertException("获取接入配置失败","UserDingtalkRegisterService","");
try {
String accessToken =dingTalkTokenService.getAccessToken(sysOpenAccess.getAccessKey(),sysOpenAccess.getSecretKey()); String accessToken =dingTalkTokenService.getAccessToken(sysOpenAccess.getAccessKey(),sysOpenAccess.getSecretKey());
sysOpenAccess.setAccessToken(accessToken); sysOpenAccess.setAccessToken(accessToken);
}
catch (Exception ex)
{
}
return sysOpenAccess; return sysOpenAccess;
} }
...@@ -93,7 +99,11 @@ public class UserDingtalkRegisterService { ...@@ -93,7 +99,11 @@ public class UserDingtalkRegisterService {
if(user==null) if(user==null)
{ {
//查不到情况下到auth表查真实userId //查不到情况下到auth表查真实userId
SysUserAuth userAuth = sysUserAuthService.getOne(Wrappers.<SysUserAuth>lambdaQuery().eq(SysUserAuth::getIdentityType,"dingtalk").eq(SysUserAuth::getIdentifier, userId),false); SysUserAuth userAuth = sysUserAuthService.getOne(Wrappers.<SysUserAuth>lambdaQuery().eq(SysUserAuth::getIdentityType,openAccess.getId()).eq(SysUserAuth::getIdentifier, userId),false);
if(userAuth==null)
userAuth = sysUserAuthService.getOne(Wrappers.<SysUserAuth>lambdaQuery().eq(SysUserAuth::getIdentityType,"dingtalk").eq(SysUserAuth::getIdentifier, userId),false);
// 该钉钉用户注册过账号,登录系统 // 该钉钉用户注册过账号,登录系统
if (userAuth!=null) { if (userAuth!=null) {
user = sysUserService.getById(userAuth.getUserid()); user = sysUserService.getById(userAuth.getUserid());
...@@ -115,8 +125,10 @@ public class UserDingtalkRegisterService { ...@@ -115,8 +125,10 @@ public class UserDingtalkRegisterService {
*/ */
public JSONObject getUserBySnsToken(String id,String requestAuthCode) { public JSONObject getUserBySnsToken(String id,String requestAuthCode) {
JSONObject returnObj = new JSONObject(); JSONObject returnObj = new JSONObject();
final String accessid = StringUtils.isEmpty(id)?"dingtalk":id;
SysOpenAccess openAccess=sysOpenAccessService.getOne(Wrappers.<SysOpenAccess>lambdaQuery().eq(SysOpenAccess::getOpenType,"dingtalk").
and(wrapper -> wrapper.eq(SysOpenAccess::getAccessKey,accessid).or().eq(SysOpenAccess::getId,accessid)),false);
SysOpenAccess openAccess = getOpenAccess(id);
if (openAccess==null || (openAccess.getDisabled()!=null && openAccess.getDisabled()==1)) if (openAccess==null || (openAccess.getDisabled()!=null && openAccess.getDisabled()==1))
throw new BadRequestAlertException("未找到配置", "UserDingtalkRegisterService", ""); throw new BadRequestAlertException("未找到配置", "UserDingtalkRegisterService", "");
...@@ -134,7 +146,12 @@ public class UserDingtalkRegisterService { ...@@ -134,7 +146,12 @@ public class UserDingtalkRegisterService {
returnObj.put("openid", response.getUserInfo().getOpenid()); returnObj.put("openid", response.getUserInfo().getOpenid());
returnObj.put("nickname", response.getUserInfo().getNick()); returnObj.put("nickname", response.getUserInfo().getNick());
returnObj.put("unionid", response.getUserInfo().getUnionid()); returnObj.put("unionid", response.getUserInfo().getUnionid());
SysUserAuth userAuth = sysUserAuthService.getOne(Wrappers.<SysUserAuth>lambdaQuery().eq(SysUserAuth::getIdentityType,"dingtalk") SysUserAuth userAuth = sysUserAuthService.getOne(Wrappers.<SysUserAuth>lambdaQuery().eq(SysUserAuth::getIdentityType,openAccess.getId())
.and(wrapper -> wrapper.eq(SysUserAuth::getIdentifier, response.getUserInfo().getOpenid()).or().eq(SysUserAuth::getIdentifier, response.getUserInfo().getUnionid())
),false);
if(userAuth==null)
userAuth = sysUserAuthService.getOne(Wrappers.<SysUserAuth>lambdaQuery().eq(SysUserAuth::getIdentityType,"dingtalk")
.and(wrapper -> wrapper.eq(SysUserAuth::getIdentifier, response.getUserInfo().getOpenid()).or().eq(SysUserAuth::getIdentifier, response.getUserInfo().getUnionid()) .and(wrapper -> wrapper.eq(SysUserAuth::getIdentifier, response.getUserInfo().getOpenid()).or().eq(SysUserAuth::getIdentifier, response.getUserInfo().getUnionid())
),false); ),false);
......
...@@ -107,7 +107,10 @@ public class UserQQRegisterService { ...@@ -107,7 +107,10 @@ public class UserQQRegisterService {
if (responseObj2.containsKey("openid")) { if (responseObj2.containsKey("openid")) {
openid = responseObj2.getString("openid"); openid = responseObj2.getString("openid");
returnObj.put("openid",openid); returnObj.put("openid",openid);
SysUserAuth userAuth = sysUserAuthService.getOne(Wrappers.<SysUserAuth>lambdaQuery().eq(SysUserAuth::getIdentityType,"qq").eq(SysUserAuth::getIdentifier, openid),false); SysUserAuth userAuth = sysUserAuthService.getOne(Wrappers.<SysUserAuth>lambdaQuery().eq(SysUserAuth::getIdentityType,openAccess.getId()).eq(SysUserAuth::getIdentifier, openid),false);
if(userAuth==null)
userAuth = sysUserAuthService.getOne(Wrappers.<SysUserAuth>lambdaQuery().eq(SysUserAuth::getIdentityType,"qq").eq(SysUserAuth::getIdentifier, openid),false);
SysUser user = null; SysUser user = null;
// 该qq用户注册过账号,登录系统 // 该qq用户注册过账号,登录系统
......
...@@ -79,7 +79,12 @@ public class UserWechatRegisterService { ...@@ -79,7 +79,12 @@ public class UserWechatRegisterService {
String unionid = returnObj.getString("unionid"); String unionid = returnObj.getString("unionid");
SysUserAuth userAuth = sysUserAuthService.getOne(Wrappers.<SysUserAuth>lambdaQuery().eq(SysUserAuth::getIdentityType,"wechat") SysUserAuth userAuth = sysUserAuthService.getOne(Wrappers.<SysUserAuth>lambdaQuery().eq(SysUserAuth::getIdentityType,openAccess.getId())
.and(wrapper -> wrapper.eq(SysUserAuth::getIdentifier, openid).or().eq(SysUserAuth::getIdentifier, unionid)
),false);
if(userAuth==null)
userAuth = sysUserAuthService.getOne(Wrappers.<SysUserAuth>lambdaQuery().eq(SysUserAuth::getIdentityType,"wechat")
.and(wrapper -> wrapper.eq(SysUserAuth::getIdentifier, openid).or().eq(SysUserAuth::getIdentifier, unionid) .and(wrapper -> wrapper.eq(SysUserAuth::getIdentifier, openid).or().eq(SysUserAuth::getIdentifier, unionid)
),false); ),false);
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册