def check_auth(api_key_token, nonce, sig, body): api_key = ApiKey.from_token(db.session, api_key_token) if not api_key: return False, "not found", None if not api_key.user.active: return False, "inactive account", None res, reason = check_hmac_auth(api_key, nonce, sig, body) if not res: return False, reason, None # update api key nonce db.session.commit() return True, "", api_key
def transfer_tx_callback(api_keys, txn): txt = json.dumps(txn) print("transfer_tx_callback: tx %s" % txt) for api_key in api_keys: print("sending 'tx' event to room %s" % api_key) socketio.emit("tx", txt, json=True, room=api_key) if not TxNotification.exists(db.session, txn["id"]): print("adding to tx notification table") api_key = ApiKey.from_token(db.session, api_key) txnoti = TxNotification(api_key.user, txn["id"]) db.session.add(txnoti) db.session.commit()
def check_auth(session, api_key_token, nonce, sig, body): # pylint: disable=import-outside-toplevel from models import ApiKey api_key = ApiKey.from_token(session, api_key_token) if not api_key: return False, AUTH_FAILED, None if not api_key.user.active: return False, AUTH_FAILED, None res, reason = check_hmac_auth(api_key, nonce, sig, body) if not res: return False, reason, None # update api key nonce session.commit() return True, "", api_key