✨ Allow access user info via numeric id
This commit is contained in:
parent
f91be512f3
commit
4695a617d7
@ -4,9 +4,9 @@
|
|||||||
<option name="autoReloadType" value="ALL" />
|
<option name="autoReloadType" value="ALL" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":bug: Fix auth cache">
|
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":sparkles: Allow get realm by numeric auto increment id">
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/internal/services/realms.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/realms.go" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/pkg/internal/http/api/userinfo_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/http/api/userinfo_api.go" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@ -45,35 +45,35 @@
|
|||||||
<option name="hideEmptyMiddlePackages" value="true" />
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
<option name="showLibraryContents" value="true" />
|
<option name="showLibraryContents" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PropertiesComponent"><![CDATA[{
|
<component name="PropertiesComponent">{
|
||||||
"keyToString": {
|
"keyToString": {
|
||||||
"DefaultGoTemplateProperty": "Go File",
|
"DefaultGoTemplateProperty": "Go File",
|
||||||
"Go Build.Backend.executor": "Debug",
|
"Go Build.Backend.executor": "Debug",
|
||||||
"Go 构建.Backend.executor": "Run",
|
"Go 构建.Backend.executor": "Run",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"RunOnceActivity.git.unshallow": "true",
|
"RunOnceActivity.git.unshallow": "true",
|
||||||
"RunOnceActivity.go.formatter.settings.were.checked": "true",
|
"RunOnceActivity.go.formatter.settings.were.checked": "true",
|
||||||
"RunOnceActivity.go.migrated.go.modules.settings": "true",
|
"RunOnceActivity.go.migrated.go.modules.settings": "true",
|
||||||
"RunOnceActivity.go.modules.automatic.dependencies.download": "true",
|
"RunOnceActivity.go.modules.automatic.dependencies.download": "true",
|
||||||
"RunOnceActivity.go.modules.go.list.on.any.changes.was.set": "true",
|
"RunOnceActivity.go.modules.go.list.on.any.changes.was.set": "true",
|
||||||
"git-widget-placeholder": "master",
|
"git-widget-placeholder": "master",
|
||||||
"go.import.settings.migrated": "true",
|
"go.import.settings.migrated": "true",
|
||||||
"go.sdk.automatically.set": "true",
|
"go.sdk.automatically.set": "true",
|
||||||
"last_opened_file_path": "/Users/littlesheep/Documents/Projects/Hypernet/Passport",
|
"last_opened_file_path": "/Users/littlesheep/Documents/Projects/Hypernet/Passport",
|
||||||
"node.js.detected.package.eslint": "true",
|
"node.js.detected.package.eslint": "true",
|
||||||
"node.js.selected.package.eslint": "(autodetect)",
|
"node.js.selected.package.eslint": "(autodetect)",
|
||||||
"nodejs_package_manager_path": "npm",
|
"nodejs_package_manager_path": "npm",
|
||||||
"run.code.analysis.last.selected.profile": "pProject Default",
|
"run.code.analysis.last.selected.profile": "pProject Default",
|
||||||
"settings.editor.selected.configurable": "preferences.intentionPowerPack",
|
"settings.editor.selected.configurable": "preferences.intentionPowerPack",
|
||||||
"ts.external.directory.path": "/Users/littlesheep/Documents/Projects/Hydrogen/Passport/web/node_modules/typescript/lib",
|
"ts.external.directory.path": "/Users/littlesheep/Documents/Projects/Hydrogen/Passport/web/node_modules/typescript/lib",
|
||||||
"vue.rearranger.settings.migration": "true"
|
"vue.rearranger.settings.migration": "true"
|
||||||
},
|
},
|
||||||
"keyToStringList": {
|
"keyToStringList": {
|
||||||
"DatabaseDriversLRU": [
|
"DatabaseDriversLRU": [
|
||||||
"postgresql"
|
"postgresql"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}]]></component>
|
}</component>
|
||||||
<component name="RecentsManager">
|
<component name="RecentsManager">
|
||||||
<key name="CopyFile.RECENT_KEYS">
|
<key name="CopyFile.RECENT_KEYS">
|
||||||
<recent name="$PROJECT_DIR$/keys" />
|
<recent name="$PROJECT_DIR$/keys" />
|
||||||
@ -159,7 +159,6 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="VcsManagerConfiguration">
|
<component name="VcsManagerConfiguration">
|
||||||
<option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" />
|
<option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" />
|
||||||
<MESSAGE value=":alien: Support better metadata encoder / decoder" />
|
|
||||||
<MESSAGE value=":bug: Bug fixes on compile time" />
|
<MESSAGE value=":bug: Bug fixes on compile time" />
|
||||||
<MESSAGE value=":bug: Fix notification order" />
|
<MESSAGE value=":bug: Fix notification order" />
|
||||||
<MESSAGE value=":bug: Fix notification order... again" />
|
<MESSAGE value=":bug: Fix notification order... again" />
|
||||||
@ -184,7 +183,8 @@
|
|||||||
<MESSAGE value=":sparkles: Authkit support check user related permission" />
|
<MESSAGE value=":sparkles: Authkit support check user related permission" />
|
||||||
<MESSAGE value=":sparkles: Authkit can get user" />
|
<MESSAGE value=":sparkles: Authkit can get user" />
|
||||||
<MESSAGE value=":bug: Fix auth cache" />
|
<MESSAGE value=":bug: Fix auth cache" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value=":bug: Fix auth cache" />
|
<MESSAGE value=":sparkles: Allow get realm by numeric auto increment id" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value=":sparkles: Allow get realm by numeric auto increment id" />
|
||||||
<option name="GROUP_MULTIFILE_MERGE_BY_DIRECTORY" value="true" />
|
<option name="GROUP_MULTIFILE_MERGE_BY_DIRECTORY" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="VgoProject">
|
<component name="VgoProject">
|
||||||
|
@ -3,8 +3,8 @@ package api
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.solsynth.dev/hypernet/passport/pkg/authkit/models"
|
"git.solsynth.dev/hypernet/passport/pkg/authkit/models"
|
||||||
"github.com/spf13/viper"
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.solsynth.dev/hypernet/passport/pkg/internal/database"
|
"git.solsynth.dev/hypernet/passport/pkg/internal/database"
|
||||||
@ -15,13 +15,18 @@ import (
|
|||||||
func getOtherUserinfo(c *fiber.Ctx) error {
|
func getOtherUserinfo(c *fiber.Ctx) error {
|
||||||
alias := c.Params("alias")
|
alias := c.Params("alias")
|
||||||
|
|
||||||
|
tx := database.C.Where("name = ?")
|
||||||
|
|
||||||
|
numericId, err := strconv.Atoi(alias)
|
||||||
|
if err == nil {
|
||||||
|
tx = tx.Where("id = ?", numericId)
|
||||||
|
}
|
||||||
|
|
||||||
var account models.Account
|
var account models.Account
|
||||||
if err := database.C.
|
if err := tx.
|
||||||
Where(&models.Account{Name: alias}).
|
|
||||||
Preload("Profile").
|
Preload("Profile").
|
||||||
Preload("Badges", func(db *gorm.DB) *gorm.DB {
|
Preload("Badges", func(db *gorm.DB) *gorm.DB {
|
||||||
prefix := viper.GetString("database.prefix")
|
return db.Order("badges.type DESC")
|
||||||
return db.Order(fmt.Sprintf("%sbadges.type DESC", prefix))
|
|
||||||
}).
|
}).
|
||||||
First(&account).Error; err != nil {
|
First(&account).Error; err != nil {
|
||||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||||
|
Loading…
Reference in New Issue
Block a user