Bladeren bron

登陆修复

YuXiang 2 jaren geleden
bovenliggende
commit
cacdf8cf15
5 gewijzigde bestanden met toevoegingen van 9 en 6 verwijderingen
  1. 0 0
      README.md
  2. 4 1
      app/system/controller/token.go
  3. 1 1
      app/system/dao/tenant.go
  4. 1 1
      app/system/dao/user.go
  5. 3 3
      util/common/common.go

+ 0 - 0
README.md


+ 4 - 1
app/system/controller/token.go

@@ -151,7 +151,7 @@ func (c *auth) Login(ctx *gin.Context) {
 	ctx.JSON(http.StatusOK, common.SuccessResponse(common.Success, rsp))
 }
 
-//checkLock 校验用户登录失败次数
+// checkLock 校验用户登录失败次数
 func checkLock() {
 
 }
@@ -205,6 +205,9 @@ func captchaGrant(token model.Token, ctx *gin.Context) (*model.UserInfo, *common
 		// 获取用户类型
 		// 根据不同用户类型调用对应的接口返回数据,用户可自行拓展
 		info.User = service.UserService.GetOne(token.TenantId, token.UserName, token.Password)
+		if info.User == nil {
+			return nil, common.ParamsInvalidResponse(model.UserNotFound, nil)
+		}
 		info.TenantId = token.TenantId
 		info.Roles = []string{"admin"}
 		if info.User != nil {

+ 1 - 1
app/system/dao/tenant.go

@@ -47,7 +47,7 @@ func (c *Tenant) GetByDomain() error {
 }
 
 func (c *Tenant) GetTenant() error {
-	return Db.Debug().Model(&c).Where("tenant_id = ? and is_deleted = 0", c.TenantId).Find(&c).Error
+	return Db.Debug().Model(&c).Where("tenant_id = ? and is_deleted = 0", c.TenantId).First(&c).Error
 }
 
 func (c *Tenant) GetTenantByPasskey() error {

+ 1 - 1
app/system/dao/user.go

@@ -44,7 +44,7 @@ func (c *User) GetUserByTenantId() error {
 }
 
 func (c *User) GetUserByPwd() error {
-	return Db.Debug().Model(&c).Where("tenant_id = ? and account = ? and password = ? and is_deleted = 0", c.TenantId, c.Account, c.Password).Find(&c).Error
+	return Db.Debug().Model(&c).Where("tenant_id = ? and account = ? and password = ? and is_deleted = 0", c.TenantId, c.Account, c.Password).First(&c).Error
 }
 
 func (c User) GetUsers(offset, limit int) ([]User, error) {

+ 3 - 3
util/common/common.go

@@ -7,7 +7,7 @@ import (
 	"time"
 )
 
-//Operation type 操作类型
+// Operation type 操作类型
 const (
 	OperationDefault          = iota
 	OperationLogin            //登录
@@ -45,7 +45,7 @@ const (
 	ModuleTypeWisdomLighting        //智能感应照明系统-灯随车走照明控制
 )
 
-//deviceType 设备类型 1** 交通 2** 农业
+// deviceType 设备类型 1** 交通 2** 农业
 const (
 	DeviceTypeDefault        = 0   //--
 	DeviceTypeCamera         = 100 //摄像头
@@ -109,7 +109,7 @@ func RandomString(n int) string {
 }
 
 func RandomString2(n int) string {
-	var letters = []rune("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
+	var letters = []rune("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
 	rand.Seed(time.Now().Unix())
 	b := make([]rune, n)
 	for i := range b {