Skip to content

Commit de204e7

Browse files
author
smallchill
committed
🎉 优化登录逻辑
1 parent 447c3d5 commit de204e7

File tree

3 files changed

+42
-2
lines changed

3 files changed

+42
-2
lines changed

blade-auth/src/main/java/org/springblade/auth/controller/AuthController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public R<AuthInfo> token(@ApiParam(value = "授权类型", required = true) @Req
5858
ITokenGranter granter = TokenGranterBuilder.getGranter(grantType);
5959
UserInfo userInfo = granter.grant(tokenParameter);
6060

61-
if (userInfo == null || userInfo.getUser() == null) {
61+
if (userInfo == null || userInfo.getUser() == null || userInfo.getUser().getId() == null) {
6262
return R.fail(TokenUtil.USER_NOT_FOUND);
6363
}
6464

blade-service-api/blade-user-api/src/main/java/org/springblade/system/user/feign/IUserClient.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
* @author Chill
3030
*/
3131
@FeignClient(
32-
value = AppConstant.APPLICATION_USER_NAME
32+
value = AppConstant.APPLICATION_USER_NAME,
33+
fallback = IUserClientFallback.class
3334
)
3435
public interface IUserClient {
3536

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springblade.system.user.feign;
17+
18+
import org.springblade.core.tool.api.R;
19+
import org.springblade.system.user.entity.UserInfo;
20+
import org.springframework.stereotype.Component;
21+
22+
/**
23+
* Feign失败配置
24+
*
25+
* @author Chill
26+
*/
27+
@Component
28+
public class IUserClientFallback implements IUserClient {
29+
30+
@Override
31+
public R<UserInfo> userInfo(Long userId) {
32+
return R.fail("未获取到账号信息");
33+
}
34+
35+
@Override
36+
public R<UserInfo> userInfo(String tenantCode, String account, String password) {
37+
return R.fail("未获取到账号信息");
38+
}
39+
}

0 commit comments

Comments
 (0)