Fix whoami endpoint

This commit is contained in:
davelopez
2022-08-24 12:05:47 +02:00
committed by mvdbeek
parent e21c665053
commit 9beeb4f1ea
+11 -6
View File
@@ -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):