|
@@ -281,19 +281,21 @@ func (l *loginAuth) getRedisKey(key string) string {
|
|
|
}
|
|
|
|
|
|
func (l *loginAuth) SubAccountAuthCode(ctx context.Context, phone string, code string) (string, error) {
|
|
|
- user, err := db.FindSubAccountByPhone(ctx, phone)
|
|
|
+ bSubAccountUser, err := db.FindSubAccountByPhone(ctx, phone)
|
|
|
phoneNumber := phone
|
|
|
- fmt.Println("login_auth", user, err)
|
|
|
+ fmt.Println("login_auth", bSubAccountUser, err)
|
|
|
if err != nil {
|
|
|
// 数据库错误
|
|
|
return "数据库错误", err
|
|
|
- } else if user == nil {
|
|
|
+ }
|
|
|
+ if bSubAccountUser == nil {
|
|
|
// 账号不存在,则判断此手机号码是否被商家主账号注册
|
|
|
- user, err := db.GetUserByPhone(ctx, phoneNumber)
|
|
|
+ bUser, err := db.GetUserByPhone(ctx, phoneNumber)
|
|
|
if err != nil {
|
|
|
// 数据库操作错误
|
|
|
return "", err
|
|
|
- } else if user == nil {
|
|
|
+ }
|
|
|
+ if bUser == nil {
|
|
|
// 没有被商家主账户注册,则可以注册
|
|
|
vcode, err := l.getSessionCode(ctx, phoneNumber)
|
|
|
if err != nil {
|
|
@@ -306,8 +308,8 @@ func (l *loginAuth) SubAccountAuthCode(ctx context.Context, phone string, code s
|
|
|
return "验证码有误", errors.New("auth fail")
|
|
|
}
|
|
|
return "1", err
|
|
|
- } else if string(user.Role) == consts.BRole {
|
|
|
- if user.AuthStatus == 1 {
|
|
|
+ } else if string(bUser.Role) == consts.BRole {
|
|
|
+ if bUser.AuthStatus == 1 {
|
|
|
// 被商家主账户注册,未认证,则可以注册
|
|
|
vcode, err := l.getSessionCode(ctx, phoneNumber)
|
|
|
if err != nil {
|
|
@@ -324,10 +326,10 @@ func (l *loginAuth) SubAccountAuthCode(ctx context.Context, phone string, code s
|
|
|
return "主账号存在", errors.New("auth fail")
|
|
|
}
|
|
|
}
|
|
|
- } else if user != nil {
|
|
|
+ } else {
|
|
|
// 子账号存在,则无法注册
|
|
|
logrus.Debugf("[AuthCode] auth fail,phone:%+v", phone)
|
|
|
- return "子账号存在", errors.New("auth fail")
|
|
|
+ return "子账号存在", errors.New("subAccount exist")
|
|
|
}
|
|
|
return "", nil
|
|
|
|