This commit is contained in:
eson
2023-09-04 17:45:58 +08:00
parent 19b10262b1
commit 0a8c323be5
6 changed files with 17 additions and 4 deletions

View File

@@ -12,7 +12,8 @@ type Config struct {
Auth types.Auth
ReplicaId uint64
MainAddress string
MainAddress string
WebsocketAddr string
OAuth struct {
Google struct {

View File

@@ -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:

View File

@@ -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)