兼容以0开头的手机号登录

This commit is contained in:
sk 2024-05-06 09:17:41 +08:00
parent 404017c33e
commit d6cb1f3266
2 changed files with 26 additions and 3 deletions

View File

@ -7,6 +7,7 @@ import (
"fmt"
"io"
"net/rpc"
"strings"
"time"
"github.com/globalsign/mgo"
@ -108,10 +109,27 @@ func (svc *AccountSvc) AccountIsExist(args *model.AccIsExistArg, ret *model.AccR
err := caccounts.Find(bson.M{"tel": args.Tel, "tagkey": args.TagKey}).One(acc)
if err != nil {
if errors.Is(err, mgo.ErrNotFound) {
ret.Tag = common.LoginNew
return nil
// 兼容8550开头的手机号,8550和855算同一个区号
if strings.HasPrefix(args.Tel, "855") {
tel := make([]byte, len(args.Tel)+1)
copy(tel, "8550")
copy(tel[4:], args.Tel[3:])
err = caccounts.Find(bson.M{"tel": string(tel), "tagkey": args.TagKey}).One(acc)
if err != nil {
if errors.Is(err, mgo.ErrNotFound) {
ret.Tag = common.LoginNew
return nil
} else {
return err
}
} else {
acc.Tel = args.Tel
caccounts.Update(bson.M{"_id": acc.AccountId}, bson.D{{"$set", bson.D{{"tel", args.Tel}}}})
}
}
} else {
return err
}
return err
}
if args.CodeValid {

View File

@ -11,6 +11,7 @@ import (
"net/url"
"regexp"
"strconv"
"strings"
"time"
"unicode/utf8"
@ -2706,6 +2707,8 @@ func CSPlayerSMSCode(s *netlib.Session, packetId int, data interface{}, sid int6
return nil
}
msg.Tel = strings.TrimPrefix(msg.GetTel(), "0")
tel := fmt.Sprint(msg.GetAreaCode(), msg.GetTel())
// tel
if !telRule.MatchString(tel) {
@ -2857,6 +2860,8 @@ func CSBindTel(s *netlib.Session, packetId int, data interface{}, sid int64) err
// return nil
//}
msg.Tel = strings.TrimPrefix(msg.GetTel(), "0")
tel := fmt.Sprint(msg.GetAreaCode(), msg.GetTel())
telKey := common.GetBindTelCodeKey(p.Platform, tel)