|
|
|
@ -3,13 +3,12 @@ from zope import component |
|
|
|
|
|
|
|
|
|
from .utils import authz_restrict_to_staff, authz_restrict_to_syscom, \ |
|
|
|
|
user_is_in_group, requires_authentication_no_realm, \ |
|
|
|
|
create_streaming_response, create_sync_response, development_only |
|
|
|
|
from ceo_common.errors import UserNotFoundError |
|
|
|
|
create_streaming_response, development_only |
|
|
|
|
from ceo_common.errors import UserNotFoundError, BadRequest |
|
|
|
|
from ceo_common.interfaces import ILDAPService |
|
|
|
|
from ceod.transactions.members import ( |
|
|
|
|
AddMemberTransaction, |
|
|
|
|
ModifyMemberTransaction, |
|
|
|
|
RenewMemberTransaction, |
|
|
|
|
DeleteMemberTransaction, |
|
|
|
|
) |
|
|
|
|
import ceod.utils as utils |
|
|
|
@ -68,12 +67,16 @@ def patch_user(auth_user: str, username: str): |
|
|
|
|
@authz_restrict_to_staff |
|
|
|
|
def renew_user(username: str): |
|
|
|
|
body = request.get_json(force=True) |
|
|
|
|
txn = RenewMemberTransaction( |
|
|
|
|
username, |
|
|
|
|
terms=body.get('terms'), |
|
|
|
|
non_member_terms=body.get('non_member_terms'), |
|
|
|
|
) |
|
|
|
|
return create_sync_response(txn) |
|
|
|
|
ldap_srv = component.getUtility(ILDAPService) |
|
|
|
|
user = ldap_srv.get_user(username) |
|
|
|
|
if body.get('terms'): |
|
|
|
|
user.add_terms(body['terms']) |
|
|
|
|
return {'terms_added': body['terms']} |
|
|
|
|
elif body.get('non_member_terms'): |
|
|
|
|
user.add_non_member_terms(body['non_member_terms']) |
|
|
|
|
return {'non_member_terms_added': body['non_member_terms']} |
|
|
|
|
else: |
|
|
|
|
raise BadRequest('Must specify either terms or non-member terms') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@bp.route('/<username>/pwreset', methods=['POST']) |
|
|
|
|