diff --git a/server/auth/etc/auth.yaml b/server/auth/etc/auth.yaml index 1caaa656..1713f5c4 100644 --- a/server/auth/etc/auth.yaml +++ b/server/auth/etc/auth.yaml @@ -3,6 +3,7 @@ Host: localhost Port: 9980 ReplicaId: 10 MainAddress: "https://server.fusen.3718.cn:9900" +WebsocketAddr: "https://server.fusen.3718.cn:9914" SourceMysql: "fsreaderwriter:XErSYmLELKMnf3Dh@tcp(fusen.cdmigcvz3rle.us-east-2.rds.amazonaws.com:3306)/fusen" Log: Stat: false diff --git a/server/auth/internal/config/config.go b/server/auth/internal/config/config.go index 16f1eb01..c8b3c6d1 100644 --- a/server/auth/internal/config/config.go +++ b/server/auth/internal/config/config.go @@ -12,7 +12,8 @@ type Config struct { Auth types.Auth ReplicaId uint64 - MainAddress string + MainAddress string + WebsocketAddr string OAuth struct { Google struct { diff --git a/server/auth/internal/logic/useremailconfirmationlogic.go b/server/auth/internal/logic/useremailconfirmationlogic.go index 3ca8ee33..6ae4fac6 100644 --- a/server/auth/internal/logic/useremailconfirmationlogic.go +++ b/server/auth/internal/logic/useremailconfirmationlogic.go @@ -57,7 +57,7 @@ func FinishRegister(svcCtx *svc.ServiceContext, user *gmodel.FsUser, token *auth event.Data = wevent.DataEmailRegister{ JwtToken: jwtToken, } - err = CommonNotify(svcCtx.Config.MainAddress, token.Wid, event) + err = CommonNotify(svcCtx.Config.WebsocketAddr, token.Wid, event) if err != nil { // logx.Error(err, token.TraceId) return err @@ -66,8 +66,8 @@ func FinishRegister(svcCtx *svc.ServiceContext, user *gmodel.FsUser, token *auth return nil } -func CommonNotify(MainAddress, wid string, event *wevent.WebsocketEvent) error { - tp := requests.Post(fmt.Sprintf("%s/api/websocket/common_notify", MainAddress)) +func CommonNotify(WebsocketAddr, wid string, event *wevent.WebsocketEvent) error { + tp := requests.Post(fmt.Sprintf("%s/api/websocket/common_notify", WebsocketAddr)) tp.SetBodyJson(requests.M{ "wid": wid, "data": event, @@ -165,6 +165,13 @@ func (l *UserEmailConfirmationLogic) UserEmailConfirmation(req *types.RequestEma return resp.SetStatus(basic.CodeDbSqlErr, err.Error()) } + event := wevent.NewWebsocketEventSuccess(wevent.UserResetToken, rt.TraceId) + err = CommonNotify(l.svcCtx.Config.MainAddress, rt.Wid, event) + if err != nil { + logx.Error(err, rt.TraceId) + return resp.SetStatus(basic.CodeResetPasswordErr, err.Error()) + } + return resp.SetStatus(basic.CodeOK) default: diff --git a/server/auth/internal/logic/userresettokenlogic.go b/server/auth/internal/logic/userresettokenlogic.go index 5210efb9..5f141663 100644 --- a/server/auth/internal/logic/userresettokenlogic.go +++ b/server/auth/internal/logic/userresettokenlogic.go @@ -36,6 +36,8 @@ func (l *UserResetTokenLogic) UserResetToken(req *types.RequestUserResetToken, u // 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data) // userinfo 传入值时, 一定不为null + return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "废弃") + user, err := l.svcCtx.AllModels.FsUser.FindUserByEmail(context.TODO(), req.Email) if err != nil { logx.Error(err) diff --git a/utils/basic/basic.go b/utils/basic/basic.go index 20fc1ccc..afce9235 100644 --- a/utils/basic/basic.go +++ b/utils/basic/basic.go @@ -57,6 +57,7 @@ var ( CodePasswordErr = &StatusResponse{5052, "invalid password"} // 无效密码 CodeEmailExistsErr = &StatusResponse{5053, "email exists"} // email存在 CodeEmailTimeShortErr = &StatusResponse{5053, "email with the time of resend is too short"} // email存在 + CodeResetPasswordErr = &StatusResponse{5054, "reset password error"} // 无效密码 CodeSafeValueRangeErr = &StatusResponse{5040, "value not in range"} // 值不在范围内 CodeTemplateErr = &StatusResponse{5040, "template parsed error"} // 模板解析错误 diff --git a/utils/wevent/base_event.go b/utils/wevent/base_event.go index 5bf4e6fd..8ce58131 100644 --- a/utils/wevent/base_event.go +++ b/utils/wevent/base_event.go @@ -9,6 +9,7 @@ type EventType string const ( UserEmailRegister EventType = "E_USER_EMAIL_REGISTER" // 用户注册 + UserResetToken EventType = "E_USER_RESET_TOKEN" // 用户重置密码成功通知 ) // WebsocketEvent 所有事件都必须继承这个结构体