增加限制条件

This commit is contained in:
hoteas
2022-05-06 11:35:40 +08:00
parent aea2e0241d
commit 4cbc84063a
7 changed files with 87 additions and 48 deletions
+9 -6
View File
@@ -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 {
+3 -2
View File
@@ -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
View File
@@ -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())
+4 -2
View File
@@ -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
+7
View File
@@ -2,6 +2,7 @@ package provider
import (
. "code.hoteas.com/golang/hotime"
"code.hoteas.com/golang/hotime/common"
"code.hoteas.com/golang/hotime/dri/ddsms"
)
@@ -20,6 +21,12 @@ var Sms = Ctr{
return
}
salesman := that.Db.Get("salesman", "id", common.Map{"phone": phone})
if salesman == nil {
that.Display(3, "你还不是企服人员,请联系管理员")
return
}
code := getCode()
that.Session("phone", phone)
that.Session("code", code)