From 60eacb6c05e6a9084456953b506fee68b1d64765 Mon Sep 17 00:00:00 2001 From: Monet Lee Date: Fri, 2 Aug 2024 19:33:05 +0800 Subject: [PATCH 1/3] update dockerfile contents. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 8090d968..c0076d9c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,7 +43,7 @@ COPY --from=builder $SERVER_DIR/start-config.yml $SERVER_DIR/ COPY --from=builder $SERVER_DIR/go.mod $SERVER_DIR/ COPY --from=builder $SERVER_DIR/go.sum $SERVER_DIR/ -RUN go get github.com/openimsdk/v0.0.14-alpha.5 +RUN go get github.com/openimsdk/gomake@v0.0.14-alpha.5 # Set the command to run when the container starts ENTRYPOINT ["sh", "-c", "mage start && tail -f /dev/null"] From d38ea02f34c4a96662c37d8112f7963f2aedc093 Mon Sep 17 00:00:00 2001 From: Monet Lee Date: Fri, 2 Aug 2024 20:05:07 +0800 Subject: [PATCH 2/3] update field. --- internal/rpc/admin/token.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/rpc/admin/token.go b/internal/rpc/admin/token.go index c06ad344..5036ba98 100644 --- a/internal/rpc/admin/token.go +++ b/internal/rpc/admin/token.go @@ -23,7 +23,7 @@ import ( "github.com/redis/go-redis/v9" ) -func (o *adminServer) CreateToken(ctx context.Context, req *admin.CreateTokenReq) (*admin.CreateTokenResp, error) { +func (o *adminServer) CreateToken(ctx context.Context, req *adminpb.CreateTokenReq) (*adminpb.CreateTokenResp, error) { token, expire, err := o.Token.CreateToken(req.UserID, req.UserType) if err != nil { From d6e41f0151a259f24fb0b5625287c6ae03999e5f Mon Sep 17 00:00:00 2001 From: Monet Lee Date: Wed, 11 Sep 2024 17:11:47 +0800 Subject: [PATCH 3/3] fix: reset UserPassword in admin. --- internal/api/admin/admin.go | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/internal/api/admin/admin.go b/internal/api/admin/admin.go index e0586939..96f15974 100644 --- a/internal/api/admin/admin.go +++ b/internal/api/admin/admin.go @@ -18,6 +18,11 @@ import ( "context" "crypto/md5" "encoding/hex" + "net/http" + "strconv" + "strings" + "time" + "github.com/gin-gonic/gin" "github.com/openimsdk/chat/internal/api/util" "github.com/openimsdk/chat/pkg/common/apistruct" @@ -37,10 +42,6 @@ import ( "github.com/openimsdk/tools/log" "github.com/openimsdk/tools/utils/datautil" "github.com/openimsdk/tools/utils/encrypt" - "net/http" - "strconv" - "strings" - "time" ) func New(chatClient chat.ChatClient, adminClient admin.AdminClient, imApiCaller imapi.CallerInterface, api *util.Api) *Api { @@ -87,7 +88,30 @@ func (o *Api) AdminLogin(c *gin.Context) { } func (o *Api) ResetUserPassword(c *gin.Context) { - a2r.Call(chat.ChatClient.ChangePassword, o.chatClient, c) + req, err := a2r.ParseRequest[chat.ChangePasswordReq](c) + if err != nil { + apiresp.GinError(c, err) + return + } + resp, err := o.chatClient.ChangePassword(c, req) + if err != nil { + apiresp.GinError(c, err) + return + } + + imToken, err := o.imApiCaller.ImAdminTokenWithDefaultAdmin(c) + if err != nil { + apiresp.GinError(c, err) + return + } + + err = o.imApiCaller.ForceOffLine(mctx.WithApiToken(c, imToken), req.UserID) + if err != nil { + apiresp.GinError(c, err) + return + } + + apiresp.GinSuccess(c, resp) } func (o *Api) AdminUpdateInfo(c *gin.Context) {