Commit c9b50f02fc03ec7c0dafe58d9fb37fd7afee7ca0

Authored by 云中非
1 parent 2524229f

feat: 组态账号授权接口

... ... @@ -74,7 +74,7 @@ public class ThingsboardSecurityConfiguration extends WebSecurityConfigurerAdapt
74 74
75 75 //Thingskit function
76 76 public static final String CODE_BASED_LOGIN_ENTRY_POINT = "/api/yt/auth/code/login";
77   - public static final String[] YT_NOT_AUTH_API = new String[]{"/api/yt/auth/code/login","/api/yt/third/bind","/api/yt/third/login/*", "/api/yt/noauth/**"};
  77 + public static final String[] YT_NOT_AUTH_API = new String[]{"/api/yt/auth/code/login","/api/yt/third/bind","/api/yt/third/login/*","/api/yt/third/login/id/*", "/api/yt/noauth/**"};
78 78
79 79 public static final String PUBLIC_LOGIN_ENTRY_POINT = "/api/auth/login/public";
80 80 public static final String TOKEN_REFRESH_ENTRY_POINT = "/api/auth/token";
... ...
... ... @@ -89,7 +89,7 @@ public class YtThirdPlatformController extends BaseController {
89 89
90 90 @GetMapping("login/{loginCode}")
91 91 @ApiOperation("第三方登录")
92   - public YtLoginResponse login(@PathVariable("loginCode") String loginCode)
  92 + public YtLoginResponse codeLogin(@PathVariable("loginCode") String loginCode)
93 93 throws ThingsboardException {
94 94 String thirdUserId = thirdService.thirdLogin(loginCode);
95 95 UserDTO userDto = thirdService.login(thirdUserId);
... ... @@ -99,6 +99,17 @@ public class YtThirdPlatformController extends BaseController {
99 99 return buildJwtToken(userDto, thirdUserId);
100 100 }
101 101
  102 + @GetMapping("login/id/{userId}")
  103 + @ApiOperation("组态用户认证")
  104 + public YtLoginResponse unionidLogin(@PathVariable("userId") String userId)
  105 + throws ThingsboardException {
  106 + UserDTO userDto = ytUserService.findUserInfoById(userId);
  107 + if (userDto == null) {
  108 + return new YtLoginResponse().setThirdUserId(userId);
  109 + }
  110 + return buildJwtToken(userDto, userId);
  111 + }
  112 +
102 113 @NotNull
103 114 private YtLoginResponse buildJwtToken(UserDTO userDto, String thirdUserId) {
104 115 String accessToken = "";
... ...