mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-04-28 14:29:19 +08:00
feat: add getUserToken api and add ex field in getSortedConversationListResp (#1880)
* fix: del the manager config and manger init statement * fix: fix the Manger judge condition * fix: fix revokeMsg error * fix: find erors * fix: find error * fix: fix the AdminAccount error * fix: del the debug statement * fix: fix the component check func * fix: fix the get zkAddress error * fix: fix the kafka client close error * fix: add env in minio connected * fix: del the minio env * fix: fix the go.mod tools version * fix: del get env in minio conneted * feat: add GetUserToken api and add ex field in GetSortedConversationList resp * fix: fix the go.mod version * fix: add lack method * fix: add a method * fix: add lack implement * fix: fix the tools pkg version * fix: del the unuser pkg * fix: add Limiting judgement of get admin token
This commit is contained in:
@@ -80,6 +80,28 @@ func (s *authServer) UserToken(ctx context.Context, req *pbauth.UserTokenReq) (*
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
func (s *authServer) GetUserToken(ctx context.Context, req *pbauth.GetUserTokenReq) (*pbauth.GetUserTokenResp, error) {
|
||||
if err := authverify.CheckAdmin(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp := pbauth.GetUserTokenResp{}
|
||||
|
||||
if authverify.IsManagerUserID(req.UserID) {
|
||||
return nil, errs.ErrNoPermission.Wrap("don't get Admin token")
|
||||
}
|
||||
|
||||
if _, err := s.userRpcClient.GetUserInfo(ctx, req.UserID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
token, err := s.authDatabase.CreateToken(ctx, req.UserID, int(req.PlatformID))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp.Token = token
|
||||
resp.ExpireTimeSeconds = config.Config.TokenPolicy.Expire * 24 * 60 * 60
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
func (s *authServer) parseToken(ctx context.Context, tokensString string) (claims *tokenverify.Claims, err error) {
|
||||
claims, err = tokenverify.GetClaimFromToken(tokensString, authverify.Secret())
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user