增加限制条件
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 {
|
||||
|
||||
Reference in New Issue
Block a user