新功能(#48): 用户封禁链路接入 (#32)

Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
2026-06-16 06:28:47 -07:00
committed by GitHub
parent 3d1a31a19f
commit 77fa0cadd2
17 changed files with 581 additions and 83 deletions
@@ -21,6 +21,7 @@ import (
"github.com/perfect-panel/server/pkg/uuidx"
"github.com/perfect-panel/server/pkg/xerr"
"github.com/pkg/errors"
"github.com/redis/go-redis/v9"
"gorm.io/gorm"
)
@@ -64,6 +65,9 @@ func (l *TelephoneLoginLogic) TelephoneLogin(req *types.TelephoneLoginRequest, r
}
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DatabaseQueryError), "query user info failed: %v", err.Error())
}
if common.IsUserDisabled(userInfo) {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.UserDisabled), "User disabled")
}
// Record login status
defer func(svcCtx *svc.ServiceContext) {
if userInfo.Id != 0 {
@@ -165,6 +169,7 @@ func (l *TelephoneLoginLogic) TelephoneLogin(req *types.TelephoneLoginRequest, r
if err = l.svcCtx.Redis.Set(l.ctx, sessionIdCacheKey, userInfo.Id, time.Duration(l.svcCtx.Config.JwtAuth.AccessExpire)*time.Second).Err(); err != nil {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.ERROR), "set session id error: %v", err.Error())
}
l.svcCtx.Redis.ZAdd(l.ctx, fmt.Sprintf("%s%d", config.UserSessionsKeyPrefix, userInfo.Id), redis.Z{Score: float64(time.Now().Unix()), Member: sessionId})
loginStatus = true
return &types.LoginResponse{
Token: token,