mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Fix whoami endpoint
This commit is contained in:
@@ -14,14 +14,17 @@ from fastapi import Path
|
||||
|
||||
from galaxy.managers.configuration import ConfigurationManager
|
||||
from galaxy.managers.context import ProvidesUserContext
|
||||
from galaxy.schema.fields import EncodedDatabaseIdField
|
||||
from galaxy.schema.fields import (
|
||||
DecodedDatabaseIdField,
|
||||
EncodedDatabaseIdField,
|
||||
)
|
||||
from galaxy.schema.schema import UserModel
|
||||
from . import (
|
||||
from galaxy.webapps.galaxy.api import (
|
||||
depends,
|
||||
DependsOnTrans,
|
||||
Router,
|
||||
)
|
||||
from .common import (
|
||||
from galaxy.webapps.galaxy.api.common import (
|
||||
parse_serialization_params,
|
||||
SerializationKeysQueryParam,
|
||||
SerializationViewQueryParam,
|
||||
@@ -50,7 +53,7 @@ class FastAPIConfiguration:
|
||||
)
|
||||
def whoami(self, trans: ProvidesUserContext = DependsOnTrans) -> Optional[UserModel]:
|
||||
"""Return information about the current authenticated user."""
|
||||
return _user_to_model(trans.user, trans.security)
|
||||
return _user_to_model(trans.user)
|
||||
|
||||
@router.get(
|
||||
"/api/configuration",
|
||||
@@ -119,8 +122,10 @@ class FastAPIConfiguration:
|
||||
self.configuration_manager.reload_toolbox()
|
||||
|
||||
|
||||
def _user_to_model(user, security):
|
||||
return UserModel(**user.to_dict(view="element", value_mapper={"id": security.encode_id})) if user else None
|
||||
def _user_to_model(user):
|
||||
if user:
|
||||
return UserModel.construct(**user.to_dict(view="element", value_mapper={"id": DecodedDatabaseIdField.encode}))
|
||||
return None
|
||||
|
||||
|
||||
def _index(manager: ConfigurationManager, trans, view, keys):
|
||||
|
||||
Reference in New Issue
Block a user