Skip to content

Commit

Permalink
Merge branch 'main' into feat/workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
mo3et authored Sep 23, 2024
2 parents 3477658 + 335efdb commit 9faccba
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions internal/api/admin/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 9faccba

Please sign in to comment.