Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop

This commit is contained in:
laodaming 2023-09-04 18:17:38 +08:00
commit baf5c887b4
6 changed files with 17 additions and 4 deletions

View File

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

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)

View File

@ -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"} // 模板解析错误

View File

@ -9,6 +9,7 @@ type EventType string
const (
UserEmailRegister EventType = "E_USER_EMAIL_REGISTER" // 用户注册
UserResetToken EventType = "E_USER_RESET_TOKEN" // 用户重置密码成功通知
)
// WebsocketEvent 所有事件都必须继承这个结构体