25 lines
615 B
Python
25 lines
615 B
Python
from aiohttp.web import json_response, View
|
|
from aiohttp.web import HTTPNotFound, HTTPUnprocessableEntity
|
|
|
|
from phi.logging import get_logger
|
|
from phi.ldap.user import get_user_by_uid
|
|
from phi.api.utils import serialize
|
|
|
|
log = get_logger(__name__)
|
|
|
|
|
|
class User(View):
|
|
async def get(self):
|
|
uid = self.request.match_info.get("uid", None)
|
|
|
|
if uid is None:
|
|
return HTTPUnprocessableEntity()
|
|
|
|
client = self.request.app["ldap_client"]
|
|
user = get_user_by_uid(client, uid)
|
|
|
|
if not user:
|
|
return HTTPNotFound()
|
|
|
|
return json_response(serialize(user))
|