This commit is contained in:
Mrx
2026-02-04 13:33:21 +08:00
parent e7c2ddbd93
commit e1fbf72437
23 changed files with 190 additions and 65 deletions

View File

@@ -2,12 +2,12 @@ package service
import (
"context"
"database/sql"
"tydata-server/app/main/api/internal/config"
"tydata-server/app/main/model"
"tydata-server/common/ctxdata"
jwtx "tydata-server/common/jwt"
"tydata-server/common/xerr"
"database/sql"
"github.com/google/uuid"
"github.com/pkg/errors"
@@ -78,6 +78,17 @@ func (s *UserService) RegisterUUIDUser(ctx context.Context) (int64, error) {
// generalUserToken 生成用户token
func (s *UserService) GeneralUserToken(ctx context.Context, userID int64, userType int64) (string, error) {
// 正式用户签发 token 前校验是否被封禁,封禁用户不允许登录
if userType == model.UserTypeNormal {
user, err := s.userModel.FindOne(ctx, userID)
if err != nil {
return "", err
}
if user != nil && user.Disable == 1 {
return "", errors.Wrapf(xerr.NewErrCode(xerr.USER_DISABLED), "用户已被封禁")
}
}
platform, err := ctxdata.GetPlatformFromCtx(ctx)
if err != nil {
return "", err