|  | @@ -10,6 +10,7 @@ import (
 | 
	
		
			
				|  |  |  	"fmt"
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	"github.com/kataras/iris/v12"
 | 
	
		
			
				|  |  | +	"github.com/spf13/viper"
 | 
	
		
			
				|  |  |  	"go.mod/services"
 | 
	
		
			
				|  |  |  	"go.mod/web/utils"
 | 
	
		
			
				|  |  |  	"go.mod/web/viewmodels"
 | 
	
	
		
			
				|  | @@ -107,21 +108,35 @@ func (c *JlEx) PostProjectAdd() {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  // 授权登陆
 | 
	
		
			
				|  |  |  func (c *JlEx) PostAuthLogin() {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	debug := getEnvInfo("DEBUG")
 | 
	
		
			
				|  |  | +	AuthUrl := "https://jl.smartcost.com.cn"
 | 
	
		
			
				|  |  | +	if debug {
 | 
	
		
			
				|  |  | +		AuthUrl = "http://jlqa.smartcost.com.cn:7002"
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  	// 1.获得数据
 | 
	
		
			
				|  |  |  	data := &viewmodels.Jl{}
 | 
	
		
			
				|  |  |  	if err := c.Ctx.ReadJSON(data); err != nil {
 | 
	
		
			
				|  |  | -		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
 | 
	
		
			
				|  |  | +		// fmt.Sprintf("%s", err)
 | 
	
		
			
				|  |  | +		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err), "data": map[string]string{
 | 
	
		
			
				|  |  | +			"redirect": AuthUrl,
 | 
	
		
			
				|  |  | +		}})
 | 
	
		
			
				|  |  |  		return
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  	// 1-1.校验是否存在TOKEN
 | 
	
		
			
				|  |  |  	if err := data.ValidateToken(); err != nil {
 | 
	
		
			
				|  |  | -		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
 | 
	
		
			
				|  |  | +		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err), "data": map[string]string{
 | 
	
		
			
				|  |  | +			"redirect": AuthUrl,
 | 
	
		
			
				|  |  | +		}})
 | 
	
		
			
				|  |  |  		return
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  	// 1-2.验证jwt
 | 
	
		
			
				|  |  |  	claims, err := utils.ValidateJwt(data.Token)
 | 
	
		
			
				|  |  |  	if err != nil {
 | 
	
		
			
				|  |  | -		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
 | 
	
		
			
				|  |  | +		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err), "data": map[string]string{
 | 
	
		
			
				|  |  | +			"redirect": AuthUrl,
 | 
	
		
			
				|  |  | +		}})
 | 
	
		
			
				|  |  |  		return
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -131,14 +146,23 @@ func (c *JlEx) PostAuthLogin() {
 | 
	
		
			
				|  |  |  		Account: fmt.Sprintf("%s", claims["account"]),
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  	if err := claimsData.ValidateProjectAdd(); err != nil {
 | 
	
		
			
				|  |  | -		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
 | 
	
		
			
				|  |  | +		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err), "data": map[string]string{
 | 
	
		
			
				|  |  | +			"redirect": AuthUrl,
 | 
	
		
			
				|  |  | +		}})
 | 
	
		
			
				|  |  |  		return
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	JlService := services.NewJlService()
 | 
	
		
			
				|  |  |  	result, err := JlService.AuthLogin(claimsData, c.Ctx.ResponseWriter())
 | 
	
		
			
				|  |  |  	if err != nil {
 | 
	
		
			
				|  |  | -		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
 | 
	
		
			
				|  |  | +		code := -1
 | 
	
		
			
				|  |  | +		if result.Enable == 0 {
 | 
	
		
			
				|  |  | +			// 计量跳转代表账号停用
 | 
	
		
			
				|  |  | +			code = 3
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		c.Ctx.JSON(iris.Map{"code": code, "msg": fmt.Sprintf("%s", err), "data": map[string]string{
 | 
	
		
			
				|  |  | +			"redirect": AuthUrl,
 | 
	
		
			
				|  |  | +		}})
 | 
	
		
			
				|  |  |  		return
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  	c.Ctx.JSON(iris.Map{
 | 
	
	
		
			
				|  | @@ -191,3 +215,8 @@ func (c *JlEx) PostAccountUpdate() {
 | 
	
		
			
				|  |  |  		"data": "",
 | 
	
		
			
				|  |  |  	})
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +func getEnvInfo(env string) bool {
 | 
	
		
			
				|  |  | +	viper.AutomaticEnv()
 | 
	
		
			
				|  |  | +	return viper.GetBool(env)
 | 
	
		
			
				|  |  | +}
 |