From 8c07a5f5d752bc1e8b9545a1a2ab3057da09b8ce Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Thu, 10 Aug 2023 16:25:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=9D=E5=AD=98=E4=B8=BA=E4=BA=86=20websocke?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go.mod | 1 + go.sum | 2 ++ server/auth/internal/logic/email_manager.go | 6 ++-- .../logic/useremailconfirmationlogic.go | 2 +- .../internal/logic/useremailregisterlogic.go | 2 +- .../internal/logic/usergoogleloginlogic.go | 4 +-- server/auth/internal/types/types.go | 2 +- server_api/home-user-auth.api | 28 +++++++++---------- utils/auth/register.go | 2 +- utils/encryption_decryption/aes_obj_test.go | 8 +++--- 10 files changed, 30 insertions(+), 27 deletions(-) diff --git a/go.mod b/go.mod index 1f76d5aa..ee7ad2dc 100644 --- a/go.mod +++ b/go.mod @@ -61,6 +61,7 @@ require ( github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 // indirect github.com/valyala/fastrand v1.1.0 // indirect github.com/valyala/histogram v1.2.0 // indirect + github.com/yhat/wsutil v0.0.0-20170731153501-1d66fa95c997 // indirect go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.14.0 // indirect golang.org/x/crypto v0.11.0 // indirect golang.org/x/exp v0.0.0-20230728194245-b0cb94b80691 // indirect diff --git a/go.sum b/go.sum index e5035777..4d1dea86 100644 --- a/go.sum +++ b/go.sum @@ -550,6 +550,8 @@ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1: github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI= +github.com/yhat/wsutil v0.0.0-20170731153501-1d66fa95c997 h1:1+FQ4Ns+UZtUiQ4lP0sTCyKSQ0EXoiwAdHZB0Pd5t9Q= +github.com/yhat/wsutil v0.0.0-20170731153501-1d66fa95c997/go.mod h1:DIGbh/f5XMAessMV/uaIik81gkDVjUeQ9ApdaU7wRKE= github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc= diff --git a/server/auth/internal/logic/email_manager.go b/server/auth/internal/logic/email_manager.go index 522fae2f..928d1230 100644 --- a/server/auth/internal/logic/email_manager.go +++ b/server/auth/internal/logic/email_manager.go @@ -117,11 +117,11 @@ func init() { EmailTasks: make(chan *EmailFormat, 10), Auth: smtp.PlainAuth( "", - "user@example.com", - "password", + "support@fusenpack.com", + "Fusenpack2021", "smtp.gmail.com", ), - FromEmail: "user@example.com", + FromEmail: "support@fusenpack.com", emailSending: make(map[string]*EmailTask, 10), ResendTimeLimit: time.Minute * 1, semaphore: make(chan struct{}, 10), // Initialize semaphore with a capacity of 10 diff --git a/server/auth/internal/logic/useremailconfirmationlogic.go b/server/auth/internal/logic/useremailconfirmationlogic.go index a41197cb..4f68c009 100644 --- a/server/auth/internal/logic/useremailconfirmationlogic.go +++ b/server/auth/internal/logic/useremailconfirmationlogic.go @@ -71,7 +71,7 @@ func (l *UserEmailConfirmationLogic) UserEmailConfirmation(req *types.RequestEma return } - log.Println(jwtToken) + log.Println(jwtToken) // 通过websocket去, 送回通道 case "facebook": diff --git a/server/auth/internal/logic/useremailregisterlogic.go b/server/auth/internal/logic/useremailregisterlogic.go index c650079e..c665e694 100644 --- a/server/auth/internal/logic/useremailregisterlogic.go +++ b/server/auth/internal/logic/useremailregisterlogic.go @@ -59,7 +59,7 @@ func (l *UserEmailRegisterLogic) UserEmailRegister(req *types.RequestEmailRegist // 确认email 重新序列化 token.Email = req.Email - token.WCId = req.WCId + token.WId = req.Wid token.GuestId = req.GuestId clurl, err := l.svcCtx.TokenManger.Generate(token) diff --git a/server/auth/internal/logic/usergoogleloginlogic.go b/server/auth/internal/logic/usergoogleloginlogic.go index 21319226..6883c187 100644 --- a/server/auth/internal/logic/usergoogleloginlogic.go +++ b/server/auth/internal/logic/usergoogleloginlogic.go @@ -67,7 +67,7 @@ func (l *UserGoogleLoginLogic) UserGoogleLogin(req *types.RequestGoogleLogin, us ctx := context.WithValue(context.Background(), oauth2.HTTPClient, customClient) var googleOauthConfig = &oauth2.Config{ - RedirectURL: "http://localhost:9900/api/user/oauth2/login/google", + RedirectURL: fmt.Sprintf("http://%s/api/user/oauth2/login/google", l.svcCtx.Config.MainAddress), ClientID: l.svcCtx.Config.OAuth.Google.Appid, ClientSecret: l.svcCtx.Config.OAuth.Google.Secret, Scopes: []string{"https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/userinfo.profile"}, @@ -79,6 +79,7 @@ func (l *UserGoogleLoginLogic) UserGoogleLogin(req *types.RequestGoogleLogin, us logx.Error(err) resp.SetStatus(basic.CodeApiErr) } + ses := requests.NewSession() ses.Config().SetProxy("socks5://127.0.0.1:1080") // 代理 为了测试功能 @@ -91,7 +92,6 @@ func (l *UserGoogleLoginLogic) UserGoogleLogin(req *types.RequestGoogleLogin, us log.Println(r.Json()) googleId := r.Json().Get("id").Int() - user, err := l.svcCtx.AllModels.FsUser.FindUserByGoogleId(context.TODO(), googleId) if err != nil { if err != gorm.ErrRecordNotFound { diff --git a/server/auth/internal/types/types.go b/server/auth/internal/types/types.go index 6295f978..d190a992 100644 --- a/server/auth/internal/types/types.go +++ b/server/auth/internal/types/types.go @@ -23,7 +23,7 @@ type RequestEmailConfirmation struct { type RequestEmailRegister struct { Email string `json:"email"` - WCId uint64 `json:"wcid"` + Wid uint64 `json:"wid"` GuestId uint64 `json:"guest_id"` RegisterToken string `json:"register_token"` } diff --git a/server_api/home-user-auth.api b/server_api/home-user-auth.api index aad50ea3..a4015c5c 100644 --- a/server_api/home-user-auth.api +++ b/server_api/home-user-auth.api @@ -10,56 +10,56 @@ info ( import "basic.api" service home-user-auth { - + // @handler UserRegisterHandler // post /api/user/register(RequestUserRegister) returns (response); @handler UserFontsHandler get /api/user/fonts(request) returns (response); - + @handler UserGetTypeHandler get /api/user/get-type(request) returns (response); - + @handler UserSaveBasicInfoHandler post /api/user/basic-info(RequestBasicInfoForm) returns (response); - + @handler UserStatusConfigHandler get /api/user/status-config(request) returns (response); - + @handler UserBasicInfoHandler get /api/user/basic-info(request) returns (response); - + @handler UserAddressListHandler get /api/user/address-list(request) returns (response); - + @handler UserAddAddressHandler post /api/user/add-address(RequestAddAddress) returns (response); - + @handler UserContactServiceHandler post /api/user/contact-service (RequestContactService) returns (response); - + // @handler UserOderListHandler // get /api/user/order-list(RequestOrderId) returns (response); - + @handler UserOderDeleteHandler post /api/user/order-delete(RequestOrderId) returns (response); //订单列表 @handler UserOrderListHandler get /api/user/order-list (UserOrderListReq) returns (response); - + //删除订单 @handler UserOrderDeleteHandler get /api/user/order-delete (UserOrderDeleteReq) returns (response); - + //取消订单 @handler UserOrderCancelHandler get /api/user/order-cancel (UserOrderCancelReq) returns (response); - + // 用户logo列表 @handler UserLogoListHandler get /api/user/logo-list (UserLogoListReq) returns (response); - + // 再来一单 @handler UserAgainOrderHandler get /api/user/one-more-order (UserAgainOrderReq) returns (response); diff --git a/utils/auth/register.go b/utils/auth/register.go index 3c3bafaa..0b3da213 100644 --- a/utils/auth/register.go +++ b/utils/auth/register.go @@ -16,7 +16,7 @@ type RegisterToken struct { OperateType // 操作的类型, 验证的token 必须要继承这个 Id int64 // 注册的 id GuestId uint64 // guest_id 需要继承 - WCId uint64 // websocket 通道id + WId uint64 // websocket 通道id Email string // email Password string // 密码 Platform string // 平台 diff --git a/utils/encryption_decryption/aes_obj_test.go b/utils/encryption_decryption/aes_obj_test.go index b9056af6..9f3c9ea5 100644 --- a/utils/encryption_decryption/aes_obj_test.go +++ b/utils/encryption_decryption/aes_obj_test.go @@ -11,7 +11,7 @@ func TestGCM(t *testing.T) { token := &auth.RegisterToken{ OperateType: auth.OpTypeRegister, Password: "fusen_password", - WCId: 123, + WId: 123, } key := "fusen123321" @@ -31,7 +31,7 @@ func BenchmarkCRT(b *testing.B) { token := &auth.RegisterToken{ OperateType: auth.OpTypeRegister, Password: "fusen_password", - WCId: 123, + WId: 123, } key := "fusen123321" @@ -52,7 +52,7 @@ func BenchmarkGCM(b *testing.B) { token := &auth.RegisterToken{ OperateType: auth.OpTypeRegister, Password: "fusen_password", - WCId: 123, + WId: 123, } key := "fusen123321" @@ -72,7 +72,7 @@ func TestCRT(t *testing.T) { token := &auth.RegisterToken{ OperateType: auth.OpTypeRegister, Password: "fusen_password", - WCId: 123, + WId: 123, } key := "fusen123321"