def post(self, data): """Transfer money from one account to another. And only the domain owner can do the operation. """ is_domain_owner = acl.context_is_domain_owner(request.headers) if not is_domain_owner: raise exception.NotAuthorized() conn = pecan.request.db_conn conn.transfer_money(request.context, data)
def before(self, state): user_id = state.request.headers.get('X-User-Id') user_name = state.request.headers.get("X-User-Name") project_id = state.request.headers.get('X-Project-Id') domain_id = state.request.headers.get('X-Domain-Id') auth_token = state.request.headers.get('X-Auth-Token') is_admin = acl.context_is_admin(state.request.headers) is_domain_owner = acl.context_is_domain_owner(state.request.headers) roles = state.request.headers.get('X-Roles', "").split(",") state.request.context = RequestContext( auth_token=auth_token, user_id=user_id, user_name=user_name, project_id=project_id, domain_id=domain_id, is_admin=is_admin, is_domain_owner=is_domain_owner, roles=roles)