pyceo/ceod/api/uwldap.py

18 lines
411 B
Python

from flask import Blueprint
from zope import component
from ceo_common.interfaces import IUWLDAPService
bp = Blueprint('uwldap', __name__)
@bp.route('/<username>')
def get_user(username: str):
uwldap_srv = component.getUtility(IUWLDAPService)
record = uwldap_srv.get(username)
if record is None:
return {
'error': 'user not found',
}, 404
return record.to_dict()