From 608c52ace6ca5a987b3d0580731a910096793c3e Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sun, 23 Jun 2024 01:07:03 +0800 Subject: [PATCH] :bug: Fix check realm member issue --- pkg/internal/services/realms.go | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/pkg/internal/services/realms.go b/pkg/internal/services/realms.go index 35af531..ab9f31f 100644 --- a/pkg/internal/services/realms.go +++ b/pkg/internal/services/realms.go @@ -13,21 +13,6 @@ import ( "reflect" ) -func GetRealm(id uint) (models.Realm, error) { - var realm models.Realm - pc, err := gap.H.DiscoverServiceGRPC("Hydrogen.Passport") - if err != nil { - return realm, err - } - response, err := proto.NewRealmsClient(pc).GetRealm(context.Background(), &proto.RealmLookupRequest{ - Id: lo.ToPtr(uint64(id)), - }) - if err != nil { - return realm, err - } - return LinkRealm(response) -} - func GetRealmWithAlias(alias string) (models.Realm, error) { var realm models.Realm pc, err := gap.H.DiscoverServiceGRPC("Hydrogen.Passport") @@ -44,12 +29,16 @@ func GetRealmWithAlias(alias string) (models.Realm, error) { } func GetRealmMember(realmId uint, userId uint) (*proto.RealmMemberResponse, error) { + var realm models.Realm + if err := database.C.Where("id = ?", realmId).First(&realm).Error; err != nil { + return nil, err + } pc, err := gap.H.DiscoverServiceGRPC("Hydrogen.Passport") if err != nil { return nil, err } response, err := proto.NewRealmsClient(pc).GetRealmMember(context.Background(), &proto.RealmMemberLookupRequest{ - RealmId: uint64(realmId), + RealmId: uint64(realm.ExternalID), UserId: lo.ToPtr(uint64(userId)), }) if err != nil {