增加限制条件
This commit is contained in:
+9
-6
@@ -47,15 +47,18 @@ func getCode() string {
|
||||
}
|
||||
|
||||
//认证公共方案
|
||||
func auth(that *Context, phone, companyName string) error {
|
||||
func auth(that *Context, phone, companyName, userName string) error {
|
||||
|
||||
user := that.Db.Get("user", "id,phone,salesman_id,company_id,provider_id", Map{"id": that.Session("user_id").ToCeilInt()})
|
||||
user := that.Db.Get("user", "id,phone,salesman_id,company_id,provider_id,name", Map{"id": that.Session("user_id").ToCeilInt()})
|
||||
if user == nil {
|
||||
return errors.New("找不到用户")
|
||||
}
|
||||
|
||||
company := that.Db.Get("company", "name,id", Map{"id": user.GetCeilInt("company_id")})
|
||||
if company == nil {
|
||||
return errors.New("找不到企业")
|
||||
}
|
||||
//手机号与原来的不同则进行绑定
|
||||
if phone != user.GetString("phone") {
|
||||
if phone != user.GetString("phone") || companyName != company.GetString("name") || user.GetString("name") != userName {
|
||||
//微信验证成功
|
||||
if that.Session("wechat_phone").ToStr() == phone {
|
||||
that.Db.Update("user", Map{"phone": phone}, Map{"id": user.GetCeilInt("id")})
|
||||
@@ -67,7 +70,7 @@ func auth(that *Context, phone, companyName string) error {
|
||||
|
||||
return errors.New("验证码错误")
|
||||
} else {
|
||||
that.Db.Update("user", Map{"phone": phone}, Map{"id": user.GetCeilInt("id")})
|
||||
that.Db.Update("user", Map{"phone": phone, "name": userName}, Map{"id": user.GetCeilInt("id")})
|
||||
if user.GetCeilInt("company_id") != 0 {
|
||||
that.Db.Update("company", Map{"phone": phone}, Map{"id": user.GetCeilInt("company_id")})
|
||||
}
|
||||
@@ -76,7 +79,7 @@ func auth(that *Context, phone, companyName string) error {
|
||||
|
||||
}
|
||||
//
|
||||
company := that.Db.Get("company", "name,id", Map{"id": user.GetCeilInt("company_id")})
|
||||
//company := that.Db.Get("company", "name,id", Map{"id": user.GetCeilInt("company_id")})
|
||||
if company != nil {
|
||||
that.Db.Update("company", Map{"name": companyName}, Map{"id": company.GetCeilInt64("id")})
|
||||
if user.GetCeilInt64("salesman_id") != 0 {
|
||||
|
||||
@@ -17,12 +17,13 @@ var OrderCtr = Ctr{
|
||||
providerId := ObjToInt(that.Req.FormValue("provider_id"))
|
||||
phone := that.Req.FormValue("phone")
|
||||
companyName := that.Req.FormValue("company_name")
|
||||
if providerId == 0 || len(phone) != 11 || len(companyName) < 4 {
|
||||
userName := that.Req.FormValue("user_name")
|
||||
if providerId == 0 || len(phone) != 11 || len(companyName) < 4 || len(userName) < 2 {
|
||||
that.Display(3, "请求参数异常")
|
||||
return
|
||||
}
|
||||
|
||||
err := auth(that, phone, companyName)
|
||||
err := auth(that, phone, companyName, userName)
|
||||
if err != nil {
|
||||
that.Display(3, err.Error())
|
||||
return
|
||||
|
||||
+7
-1
@@ -65,8 +65,14 @@ var UpanCtr = Ctr{
|
||||
|
||||
phone := that.Req.FormValue("phone")
|
||||
companyName := that.Req.FormValue("company_name")
|
||||
userName := that.Req.FormValue("user_name")
|
||||
|
||||
if len(phone) != 11 || len(companyName) < 4 || len(userName) < 2 {
|
||||
that.Display(3, "请求参数异常")
|
||||
return
|
||||
}
|
||||
//验证不成功则反馈
|
||||
err := auth(that, phone, companyName)
|
||||
err := auth(that, phone, companyName, userName)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
that.Display(3, err.Error())
|
||||
|
||||
@@ -18,7 +18,8 @@ var VipOrderCtr = Ctr{
|
||||
|
||||
phone := that.Req.FormValue("phone")
|
||||
companyName := that.Req.FormValue("company_name")
|
||||
if len(phone) != 11 || len(companyName) < 4 {
|
||||
userName := that.Req.FormValue("user_name")
|
||||
if len(phone) != 11 || len(companyName) < 4 || len(userName) < 2 {
|
||||
that.Display(3, "请求参数异常")
|
||||
return
|
||||
}
|
||||
@@ -37,7 +38,8 @@ var VipOrderCtr = Ctr{
|
||||
return
|
||||
}
|
||||
|
||||
err := auth(that, phone, companyName)
|
||||
err := auth(that, phone, companyName, userName)
|
||||
|
||||
if err != nil {
|
||||
that.Display(3, err.Error())
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user