Browse Source

优化用户密码次数登录问题
优化bearer校验为空可以为空登录的问题
优化多数据源GlobalConfig配置实例化问题

linzhiwei 2 years ago
parent
commit
2749565e18

+ 2 - 1
common-oauth/src/main/java/com/tofly/common/oauth/auth/ToflyUser.java

@@ -42,7 +42,7 @@ public class ToflyUser extends User{
     private String companyName;
 
 
-    public ToflyUser(Long parentCompanyId,String parentCompanyName,Long companyId,String companyName,Long useid,Long departmentId,String userLevel,String realName, String departemntName,String avatar,
+    public ToflyUser(Short pwderrtimes,Long parentCompanyId,String parentCompanyName,Long companyId,String companyName,Long useid,Long departmentId,String userLevel,String realName, String departemntName,String avatar,
                      String username, String password, boolean enabled, boolean accountNonExpired,
                      boolean credentialsNonExpired, boolean accountNonLocked, Collection<? extends GrantedAuthority> authorities) {
         super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);
@@ -56,6 +56,7 @@ public class ToflyUser extends User{
         this.realName=realName;
         this.departemntName=departemntName;
         this.avatar=avatar;
+        this.pwderrtimes=pwderrtimes;
     }
 
     public ToflyUser(Short pwderrtimes,Long useid,Long departmentId,String userLevel,String realName, String departemntName,String avatar,

+ 6 - 2
common-oauth/src/main/java/com/tofly/common/oauth/compent/ToFlyUserAuthenticationConverter.java

@@ -2,6 +2,7 @@ package com.tofly.common.oauth.compent;
 
 import com.tofly.common.core.constant.SecurityConstants;
 import com.tofly.common.oauth.auth.ToflyUser;
+import com.tofly.common.oauth.exception.ToflyAuth2Exception;
 import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
 import org.springframework.security.core.Authentication;
 import org.springframework.security.core.GrantedAuthority;
@@ -63,11 +64,14 @@ public class ToFlyUserAuthenticationConverter implements UserAuthenticationConve
                 parentCompanyId = ((Integer) map.get(SecurityConstants.COMPANY_ID)).longValue();
             }
             String companyName = (String)map.get(SecurityConstants.COMPANY_NAME);
-            ToflyUser user = new ToflyUser(parentCompanyId,parentCompanyName,companyId,companyName,id, deptId, userLevel,realName,deptName,avatar,username, N_A, true
+            Short pwderrtimes = (Short) map.get("pwderrtimes");
+            ToflyUser user = new ToflyUser(pwderrtimes,parentCompanyId,parentCompanyName,companyId,companyName,id, deptId, userLevel,realName,deptName,avatar,username, N_A, true
                     , true, true, true, authorities);
             return new UsernamePasswordAuthenticationToken(user, N_A, authorities);
+        }else {
+            throw new ToflyAuth2Exception("参数非法");
         }
-        return null;
+
     }
 
     private Collection<? extends GrantedAuthority> getAuthorities(Map<String, ?> map) {

+ 2 - 0
common-orm-mybatisplus/src/main/java/com/tofly/mybatisplus/config/MybatisPlusConfigurer.java

@@ -12,6 +12,7 @@ import org.apache.ibatis.reflection.MetaObject;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Scope;
 
 import java.util.Collections;
 import java.util.HashMap;
@@ -74,6 +75,7 @@ public class MybatisPlusConfigurer {
      * @return
      */
     @Bean
+    @Scope("prototype")
     public GlobalConfig globalConfig() {
         GlobalConfig globalConfig = new GlobalConfig();
         globalConfig.setMetaObjectHandler(new MybatisPlusHandler());