mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-10 03:56:00 +08:00
1
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
commonDB "Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/tools"
|
||||
"Open_IM/pkg/common/trace_log"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
@@ -142,6 +143,13 @@ func IsManagerUserID(OpUserID string) bool {
|
||||
}
|
||||
}
|
||||
|
||||
func CheckManagerUserID(ctx context.Context) error {
|
||||
if utils.IsContain(tools.OpUserID(ctx), config.Config.Manager.AppManagerUid) {
|
||||
return nil
|
||||
}
|
||||
return constant.ErrIdentity.Wrap(utils.GetSelfFuncName())
|
||||
}
|
||||
|
||||
func CheckAccess(ctx context.Context, OpUserID string, OwnerUserID string) bool {
|
||||
if utils.IsContain(OpUserID, config.Config.Manager.AppManagerUid) {
|
||||
return true
|
||||
@@ -165,6 +173,20 @@ func CheckAccessV2(ctx context.Context, OpUserID string, OwnerUserID string) (er
|
||||
return utils.Wrap(constant.ErrIdentity, open_utils.GetSelfFuncName())
|
||||
}
|
||||
|
||||
func CheckAccessV3(ctx context.Context, OwnerUserID string) (err error) {
|
||||
opUserID := tools.OpUserID(ctx)
|
||||
defer func() {
|
||||
trace_log.SetCtxInfo(ctx, utils.GetFuncName(1), err, "OpUserID", opUserID, "OwnerUserID", OwnerUserID)
|
||||
}()
|
||||
if utils.IsContain(opUserID, config.Config.Manager.AppManagerUid) {
|
||||
return nil
|
||||
}
|
||||
if opUserID == OwnerUserID {
|
||||
return nil
|
||||
}
|
||||
return utils.Wrap(constant.ErrIdentity, open_utils.GetSelfFuncName())
|
||||
}
|
||||
|
||||
func GetUserIDFromToken(token string, operationID string) (bool, string, string) {
|
||||
claims, err := ParseToken(token, operationID)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user