diff --git a/.idea/dataSources.local.xml b/.idea/dataSources.local.xml index d964ec4..52680d5 100644 --- a/.idea/dataSources.local.xml +++ b/.idea/dataSources.local.xml @@ -1,6 +1,6 @@ - + " diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 989392c..38ffad8 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -4,13 +4,9 @@ - - + - - - - + @@ -197,19 +194,14 @@ - file://$PROJECT_DIR$/pkg/internal/services/auth.go - 105 - - file://$PROJECT_DIR$/pkg/internal/services/auth.go - 90 - - - file://$PROJECT_DIR$/pkg/internal/services/auth.go - 45 - diff --git a/pkg/internal/services/realms.go b/pkg/internal/services/realms.go index 597a239..4a9e6e3 100644 --- a/pkg/internal/services/realms.go +++ b/pkg/internal/services/realms.go @@ -5,6 +5,7 @@ import ( "git.solsynth.dev/hypernet/passport/pkg/authkit/models" "git.solsynth.dev/hypernet/passport/pkg/internal/database" "github.com/samber/lo" + "strconv" ) func ListCommunityRealm() ([]models.Realm, error) { @@ -48,10 +49,15 @@ func ListAvailableRealm(user models.Account) ([]models.Realm, error) { } func GetRealmWithAlias(alias string) (models.Realm, error) { + tx := database.C.Where("alias = ?", alias) + + numericId, err := strconv.Atoi(alias) + if err == nil { + tx.Or("id = ?", numericId) + } + var realm models.Realm - if err := database.C.Where(&models.Realm{ - Alias: alias, - }).First(&realm).Error; err != nil { + if err := tx.First(&realm).Error; err != nil { return realm, err } return realm, nil