|
|
@@ -9,9 +9,12 @@ import com.alipay.api.DefaultAlipayClient;
|
|
|
import com.alipay.api.request.AlipaySystemOauthTokenRequest;
|
|
|
import com.alipay.api.response.AlipaySystemOauthTokenResponse;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.jzg.client.OrganizationClient;
|
|
|
import com.jzg.commons.constants.RedisKeyConstants;
|
|
|
import com.jzg.commons.constants.SystemConstants;
|
|
|
+import com.jzg.commons.core.page.HttpResult;
|
|
|
import com.jzg.commons.entity.po.*;
|
|
|
+import com.jzg.commons.entity.user.vo.SysTennatVo;
|
|
|
import com.jzg.commons.entity.vo.SysRoleDataScopeVo;
|
|
|
import com.jzg.commons.util.MinioUtils;
|
|
|
import com.jzg.commons.util.StringUtils;
|
|
|
@@ -38,6 +41,7 @@ import org.springframework.security.core.AuthenticationException;
|
|
|
import org.springframework.security.core.userdetails.UserDetailsService;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
+import java.io.Serial;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
@@ -50,6 +54,8 @@ public class JzgAuthenticationProvider implements AuthenticationProvider {
|
|
|
private static final Logger log = LoggerFactory.getLogger(JzgAuthenticationProvider.class);
|
|
|
|
|
|
private UserDetailsService userDetailsService;
|
|
|
+ @Autowired
|
|
|
+ private OrganizationClient organizationClient;
|
|
|
|
|
|
private SysUserService sysUserService;
|
|
|
|
|
|
@@ -88,6 +94,13 @@ public class JzgAuthenticationProvider implements AuthenticationProvider {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 网页端登录和手机app登录使用同一个登录接口
|
|
|
+ * systemCode为APP的时候表示手机app登录(手机app端会传systemCode为APP)
|
|
|
+ *
|
|
|
+ * @author lipf
|
|
|
+ * @date 2026/4/29 11:27
|
|
|
+ */
|
|
|
@Override
|
|
|
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
|
|
|
// 获取用户名和密码
|
|
|
@@ -101,8 +114,8 @@ public class JzgAuthenticationProvider implements AuthenticationProvider {
|
|
|
String type = ((JzgUsernamePasswordAuthenticationToken)authentication).getType();
|
|
|
String code = ((JzgUsernamePasswordAuthenticationToken)authentication).getCode();
|
|
|
boolean appLogin = ((JzgUsernamePasswordAuthenticationToken)authentication).isAppLogin();
|
|
|
- log.info("登录认证:username=[{}],rawPassword=[{}],details=[{}],system=[{}], captchaId=[{}], captcha=[{}],type=[{}],code=[{}],appLogin=[{}]",
|
|
|
- username,rawPassword,details,system, captchaId, captcha, type, code, appLogin);
|
|
|
+ log.info("登录认证:username=[{}],details=[{}],system=[{}], captchaId=[{}], captcha=[{}],type=[{}],code=[{}],appLogin=[{}]",
|
|
|
+ username,details,system, captchaId, captcha, type, code, appLogin);
|
|
|
boolean isFirst = false;
|
|
|
//调试时注销验证码
|
|
|
//验证码校验
|
|
|
@@ -135,7 +148,12 @@ public class JzgAuthenticationProvider implements AuthenticationProvider {
|
|
|
}
|
|
|
salt = weblogUser.getSalt();
|
|
|
}
|
|
|
-
|
|
|
+ // modify by lipf, 用户所属租户如果被禁用,不能登录
|
|
|
+ HttpResult<List<SysTennatVo>> tenants = organizationClient.getTenantList();
|
|
|
+ if(CollectionUtil.isEmpty(tenants.getData())){
|
|
|
+ log.info("用户[{}]所属的租户已经被禁用,无法登录",username);
|
|
|
+ throw new SystemException("用户所属的租户已经被禁用,无法登录");
|
|
|
+ }
|
|
|
//检验短信验证码
|
|
|
if(Objects.nonNull(code)){
|
|
|
String systemSmsCode = redissonClient.getBucket(RedisKeyConstants.SMS_CODE + username).get().toString();
|
|
|
@@ -346,7 +364,11 @@ public class JzgAuthenticationProvider implements AuthenticationProvider {
|
|
|
details = detailMap;
|
|
|
|
|
|
Object finalDetails = details;
|
|
|
- return new UsernamePasswordAuthenticationToken(username, rawPassword, authorities) {{
|
|
|
+ return new UsernamePasswordAuthenticationToken(username, rawPassword, authorities) {
|
|
|
+ @Serial
|
|
|
+ private static final long serialVersionUID = 6103193211327672348L;
|
|
|
+
|
|
|
+ {
|
|
|
setDetails(finalDetails);
|
|
|
}};
|
|
|
}
|