提交 2564b22d 编写于 作者: nancy's avatar nancy

钉钉认证。

上级 5f927fc5
...@@ -15,7 +15,6 @@ import cn.ibizlab.util.security.AuthenticationUser; ...@@ -15,7 +15,6 @@ import cn.ibizlab.util.security.AuthenticationUser;
import cn.ibizlab.util.service.AuthenticationUserService; import cn.ibizlab.util.service.AuthenticationUserService;
import cn.ibizlab.util.service.IBZUSERService; import cn.ibizlab.util.service.IBZUSERService;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
...@@ -72,8 +71,8 @@ public class UserDingtalkRegisterResource { ...@@ -72,8 +71,8 @@ public class UserDingtalkRegisterResource {
* @return * @return
*/ */
@PostMapping(value = "/uaa/queryDingtalkUserByCode") @PostMapping(value = "/uaa/queryDingtalkUserByCode")
public ResponseEntity<JSONObject> queryDingtalkUserByCode(@RequestParam(value = "id",required = false) String id,@RequestParam(value = "code",required = false) String tmpcode,@RequestBody JSONObject param) { public ResponseEntity<AuthenticationInfo> queryDingtalkUserByCode(@RequestParam(value = "id",required = false) String id,@RequestParam(value = "code",required = false) String tmpcode,@RequestBody JSONObject param) {
JSONObject object = new JSONObject();
// 空校验 // 空校验
String code = param.getString("code"); String code = param.getString("code");
if (StringUtils.isEmpty(code)) if (StringUtils.isEmpty(code))
...@@ -81,7 +80,19 @@ public class UserDingtalkRegisterResource { ...@@ -81,7 +80,19 @@ public class UserDingtalkRegisterResource {
if (StringUtils.isEmpty(code)) if (StringUtils.isEmpty(code))
throw new BadRequestAlertException("code为空", "UserDingtalkRegisterResource", ""); throw new BadRequestAlertException("code为空", "UserDingtalkRegisterResource", "");
return ResponseEntity.ok().body(getUserBySnsCode(id,code)); AuthenticationUser ibzuser = userDingtalkRegisterService.getUserByToken(id,code);
// 生成登录token信息
String tokenUsername = ibzuser.getLoginname()+(StringUtils.isEmpty(ibzuser.getDomain())?"":("|"+ibzuser.getDomain()));
userDetailsService.resetByUsername(tokenUsername);
AuthenticationUser user = userDetailsService.loadUserByUsername(tokenUsername);
final String token = jwtTokenUtil.generateToken(user);
AuthenticationUser user2 = new AuthenticationUser();
CachedBeanCopier.copy(user, user2);
user2.setAuthorities(null);
user2.setPermissionList(null);
return ResponseEntity.ok().body(new AuthenticationInfo(token,user2));
} }
@GetMapping(value = "/uaa/open/dingtalk/sns/{code}") @GetMapping(value = "/uaa/open/dingtalk/sns/{code}")
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册