f
This commit is contained in:
@@ -97,6 +97,10 @@ func (l *BindMobileLogic) BindMobile(req *types.BindMobileReq) (resp *types.Bind
|
||||
|
||||
token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID, model.UserTypeNormal)
|
||||
if err != nil {
|
||||
causeErr := errors.Cause(err)
|
||||
if _, ok := causeErr.(*xerr.CodeError); ok {
|
||||
return nil, err
|
||||
}
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "绑定手机号, 生成token失败: %+v", err)
|
||||
}
|
||||
now := time.Now().Unix()
|
||||
|
||||
@@ -2,9 +2,9 @@ package user
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
"tydata-server/common/ctxdata"
|
||||
"tydata-server/common/xerr"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
@@ -35,6 +35,10 @@ func (l *GetTokenLogic) GetToken() (resp *types.MobileCodeLoginResp, err error)
|
||||
}
|
||||
token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, claims.UserId, claims.UserType)
|
||||
if err != nil {
|
||||
causeErr := errors.Cause(err)
|
||||
if _, ok := causeErr.(*xerr.CodeError); ok {
|
||||
return nil, err
|
||||
}
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "用户信息, %v", err)
|
||||
}
|
||||
// 获取当前时间戳
|
||||
|
||||
@@ -68,7 +68,12 @@ func (l *MobileCodeLoginLogic) MobileCodeLogin(req *types.MobileCodeLoginReq) (r
|
||||
}
|
||||
token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID, model.UserTypeNormal)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "手机登录, 生成token失败 : %d", userID)
|
||||
// 封禁等业务错误原样返回,便于前端展示「用户已被封禁」
|
||||
causeErr := errors.Cause(err)
|
||||
if _, ok := causeErr.(*xerr.CodeError); ok {
|
||||
return nil, err
|
||||
}
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "手机登录, 生成token失败 : %d, %v", userID, err)
|
||||
}
|
||||
|
||||
// 获取当前时间戳
|
||||
|
||||
@@ -2,13 +2,13 @@ package user
|
||||
|
||||
import (
|
||||
"context"
|
||||
"tydata-server/app/main/model"
|
||||
"tydata-server/common/xerr"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"time"
|
||||
"tydata-server/app/main/model"
|
||||
"tydata-server/common/xerr"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
@@ -82,6 +82,10 @@ func (l *WxH5AuthLogic) WxH5Auth(req *types.WXH5AuthReq) (resp *types.WXH5AuthRe
|
||||
// Step 4: 生成JWT Token
|
||||
token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID, userType)
|
||||
if err != nil {
|
||||
causeErr := errors.Cause(err)
|
||||
if _, ok := causeErr.(*xerr.CodeError); ok {
|
||||
return nil, err
|
||||
}
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "生成JWT token失败: %v", err)
|
||||
}
|
||||
|
||||
|
||||
@@ -81,6 +81,10 @@ func (l *WxMiniAuthLogic) WxMiniAuth(req *types.WXMiniAuthReq) (resp *types.WXMi
|
||||
// 4. 生成JWT Token
|
||||
token, err := l.svcCtx.UserService.GeneralUserToken(l.ctx, userID, userType)
|
||||
if err != nil {
|
||||
causeErr := errors.Cause(err)
|
||||
if _, ok := causeErr.(*xerr.CodeError); ok {
|
||||
return nil, err
|
||||
}
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "生成JWT Token失败: %v", err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user