Skip to content

Commit

Permalink
fix: fix the go mod and fix the reset password bug (#370)
Browse files Browse the repository at this point in the history
* feat: add some api about admin

* feat: add some api about admin

* fix: del the unuse method

* fix: Optimized code

* fix: fix the userID

* fix: del the config code getting from zk

* fix: fix the initRedis

* fix: add the get Evn method in Config

* fix: fix the config.yaml.template

* fix: fix the env config

* feat: add some conponent env

* fix: fix the openIMURL

* fix: find the zk don't connect error

* fix: find the zk error

* fix: test the jz error

* fix: delt the log

* fix: fix the component error

* fix: fix the error of get env  location

* fix: fix the error

* fix: fix the zk start error

* fix: fix the Config

* fix: testing

* fix: fix the config.Env error

* fix: fix the componentCheck

* fix: fix the config

* fix: find the error

* fix: del the flag

* fix: fix the error

* fix: fix the password error

* fix: del the proxyHeader field

* fix: fix the openIMurl

* feat: add chatAdmin

* fix: fix the go mod

* fix: fix the password reset error

* fix: fix the func name

* fix: fix the reset password error
  • Loading branch information
luhaoling committed Jan 9, 2024
1 parent 0fe20f1 commit c39bfb9
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 15 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ require (

require (
github.com/OpenIMSDK/protocol v0.0.21
github.com/OpenIMSDK/tools v0.0.22
github.com/OpenIMSDK/tools v0.0.23
github.com/go-zookeeper/zk v1.0.3
github.com/redis/go-redis/v9 v9.1.0
github.com/xuri/excelize/v2 v2.8.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ github.com/OpenIMSDK/open_utils v1.0.8 h1:IopxWgJwEF5ZAPsRuiZZOfcxNOQOCt/p8VDENc
github.com/OpenIMSDK/open_utils v1.0.8/go.mod h1:FLoaQblWUVKQgqt2LrNzfSZLT6D3DICBn1kcOMDLUOI=
github.com/OpenIMSDK/protocol v0.0.21 h1:5H6H+hJ9d/VgRqttvxD/zfK9Asd+4M8Eknk5swSbUVY=
github.com/OpenIMSDK/protocol v0.0.21/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y=
github.com/OpenIMSDK/tools v0.0.22 h1:gjcqA+lWjvF2NRX9R4c9gLfFOI/bwVctT14bs1U3HpU=
github.com/OpenIMSDK/tools v0.0.22/go.mod h1:eg+q4A34Qmu73xkY0mt37FHGMCMfC6CtmOnm0kFEGFI=
github.com/OpenIMSDK/tools v0.0.23 h1:xozfrGzhbpNPlDTap5DLVPk+JfgZ/ZyIj4Cuu3/bm9w=
github.com/OpenIMSDK/tools v0.0.23/go.mod h1:eg+q4A34Qmu73xkY0mt37FHGMCMfC6CtmOnm0kFEGFI=
github.com/alibabacloud-go/alibabacloud-gateway-spi v0.0.4 h1:iC9YFYKDGEy3n/FtqJnOkZsene9olVspKmkX5A2YBEo=
github.com/alibabacloud-go/alibabacloud-gateway-spi v0.0.4/go.mod h1:sCavSAvdzOjul4cEqeVtvlSaSScfNsTQ+46HwlTL1hc=
github.com/alibabacloud-go/darabonba-openapi v0.1.18/go.mod h1:PB4HffMhJVmAgNKNq3wYbTUlFvPgxJpTzd1F5pTuUsc=
Expand Down
19 changes: 11 additions & 8 deletions internal/rpc/chat/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package chat

import (
"github.com/OpenIMSDK/chat/pkg/common/apicall"
"github.com/OpenIMSDK/tools/discoveryregistry"
"google.golang.org/grpc"

Expand Down Expand Up @@ -56,17 +57,19 @@ func Start(discov discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) e
panic(err)
}
chat.RegisterChatServer(server, &chatSvr{
Database: database.NewChatDatabase(db),
Admin: chatClient.NewAdminClient(discov),
SMS: s,
Mail: email,
Database: database.NewChatDatabase(db),
Admin: chatClient.NewAdminClient(discov),
SMS: s,
Mail: email,
imApiCaller: apicall.NewCallerInterface(),
})
return nil
}

type chatSvr struct {
Database database.ChatDatabaseInterface
Admin *chatClient.AdminClient
SMS sms.SMS
Mail email.Mail
Database database.ChatDatabaseInterface
Admin *chatClient.AdminClient
SMS sms.SMS
Mail email.Mail
imApiCaller apicall.CallerInterface
}
13 changes: 13 additions & 0 deletions internal/rpc/chat/password.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ package chat

import (
"context"
"github.com/OpenIMSDK/chat/pkg/common/config"
constant2 "github.com/OpenIMSDK/protocol/constant"
"github.com/OpenIMSDK/tools/log"

"github.com/OpenIMSDK/tools/errs"
Expand Down Expand Up @@ -103,5 +105,16 @@ func (o *chatSvr) ChangePassword(ctx context.Context, req *chat.ChangePasswordRe
return nil, err
}
}

imToken, err := o.imApiCaller.UserToken(ctx, config.GetIMAdmin(mctx.GetOpUserID(ctx)), constant2.AdminPlatformID)
if err != nil {
return nil, err
}

err = o.imApiCaller.ForceOffLine(mctx.WithApiToken(ctx, imToken), req.UserID)
if err != nil {
return nil, err
}

return &chat.ChangePasswordResp{}, nil
}
4 changes: 0 additions & 4 deletions pkg/proto/chat/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,6 @@ func (x *ChangePasswordReq) Check() error {
return errs.ErrArgs.Wrap("userID is empty")
}

if x.CurrentPassword == "" {
return errs.ErrArgs.Wrap("currentPassword is empty")
}

if x.NewPassword == "" {
return errs.ErrArgs.Wrap("newPassword is empty")
}
Expand Down

0 comments on commit c39bfb9

Please sign in to comment.