Python CSC Electronic Office
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.0 KiB

from flask import Blueprint, request
from flask.json import jsonify
from zope import component
from .utils import authz_restrict_to_syscom, is_truthy
from ceo_common.interfaces import IUWLDAPService, ILDAPService
bp = Blueprint('uwldap', __name__)
def get_user(username: str):
uwldap_srv = component.getUtility(IUWLDAPService)
record = uwldap_srv.get_user(username)
if record is None:
return {
'error': 'user not found',
}, 404
return record.to_dict()
@bp.route('/updateprograms', methods=['POST'])
def update_programs():
ldap_srv = component.getUtility(ILDAPService)
if request.headers.get('content-type') == 'application/json':
body = request.get_json()
body = {}
kwargs = {'members': body.get('members')}
if body.get('dry_run') or is_truthy(request.args.get('dry_run', 'false')):
kwargs['dry_run'] = True
return jsonify(