This commit is contained in:
2025-12-10 13:10:39 +08:00
parent c23ab8338b
commit 0f676d3c76
31 changed files with 375 additions and 5916 deletions

View File

@@ -1,10 +1,10 @@
package middleware
import (
"net/http"
"ycc-server/app/main/model"
"ycc-server/common/ctxdata"
"ycc-server/common/xerr"
"net/http"
"github.com/pkg/errors"
"github.com/zeromicro/go-zero/rest/httpx"
@@ -24,8 +24,10 @@ func (m *UserAuthInterceptorMiddleware) Handle(next http.HandlerFunc) http.Handl
httpx.Error(w, errors.Wrapf(xerr.NewErrCode(ErrCodeUnauthorized), "token解析失败: %v", err))
return
}
// 检查用户是否绑定了mobile没有mobile表示是临时用户不允许访问需要认证的接口
// 注:临时用户现在基于 mobile 字段判断,而不是 UserType
if claims.UserType == model.UserTypeTemp {
httpx.Error(w, errors.Wrapf(xerr.NewErrCode(xerr.USER_NEED_BIND_MOBILE), "token解析失败: %v", err))
httpx.Error(w, errors.Wrapf(xerr.NewErrCode(xerr.USER_NEED_BIND_MOBILE), "请先绑定手机号: %v", err))
return
}
next(w, r)