Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def confirm_account(request, token):
try:
user = db.session.query(User).filter_by(UUID=token).first()
if not user:
return response.json({"error": "No user for given token"}, 400)
user.isVerified = True
db.session.commit()
resp = user.serialize(jwt=True)
resp["success"] = "User account confirmed"
return response.json(resp, 200)
except Exception as e:
return utils.exeption_handler(e, "User confirmation failed", 500)
'tasks.count': len(tasks),
'tasks': grouped_tasks
}
except Exception as e:
logger.error('error adding cache info', e=e)
data = {
'source_commit': http_request.app.config.args.source_commit,
'docker_tag': http_request.app.config.args.docker_tag,
'jussi_num': http_request.app.config.last_irreversible_block_num,
'asyncio': async_data,
'cache': cache_data,
'server': server_data,
'ws_pools': ws_pools
}
return response.json(data)
# pylint: enable=protected-access, too-many-locals, no-member, unused-variable
async def health(_: Request) -> HTTPResponse:
return response.json({"status": "ok"})
async def get_all_contacts(request):
"""Fetches complete details of all Accounts in state"""
LOGGER.debug("Call 'contract' request")
client_key = general.get_request_key_header(request)
contract_list = await security_messaging.get_contracts(request.app.config.VAL_CONN, client_key)
contract_list_json = []
for address, con in contract_list.items():
contract_list_json.append({
'client_pkey': con.client_pkey,
'id': con.id,
'name': con.name,
'surname': con.surname
})
return response.json(body={'data': contract_list_json},
headers=general.get_response_headers())
async def create_user(request):
if request.app.config.OPEN_REGISTRATION:
username = request.json["username"]
if username:
is_uniq = await User.is_unique(doc=dict(username=username))
if is_uniq in (True, None):
await User.insert_one(dict(username=username,
password=request.json["password"],
email=request.json["email"]))
return response.json({'peremoga': 'yep'}, status=201)
else:
return response.json({'zrada': 'username n/a'})
return response.json({'zrada': 'nope'})
def render(self, templates, **context):
template = self.jinja_env.select_template(templates)
select_templates = ['{}{}'.format(
'*' if template_name == template.name else '',
template_name
) for template_name in templates]
return response.html(
template.render({
**context, **{
'app_css_hash': self.ds.app_css_hash(),
'select_templates': select_templates,
}
async def get(self, request):
try:
userId = utils.get_id_from_jwt(request)
user = utils.get_account_by_id(userId)
if not user:
return response.json({"error": "User not found"}, 404)
return response.json(user.serialize(), 200)
except Exception as e:
return utils.exeption_handler(e, "User not found", 400)
async def ui_full_timeline(request, user):
template = env.get_template('reporting_full_timeline.html')
if use_ssl:
content = template.render(links=await respect_pivot(links, request), name=user['username'], http="https", ws="wss", config=user['ui_config'])
else:
content = template.render(links=await respect_pivot(links, request), name=user['username'], http="http", ws="ws", config=user['ui_config'])
return response.html(content)
async def cb_get_creds(self, request, project_uuid):
targets = request.json['targets']
get_result = self.creds_manager.get_creds(targets=targets, project_uuid=project_uuid)
return response.json(get_result)