Put extensions back so we can start converting

This commit is contained in:
Ben Arc
2021-08-20 12:44:03 +01:00
parent bfd9ca68e4
commit fe123d6d31
273 changed files with 26031 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
from base64 import b64decode
from quart import jsonify, g, request
from functools import wraps
from lnbits.core.crud import get_wallet_for_key
def check_wallet(requires_admin=False):
def wrap(view):
@wraps(view)
async def wrapped_view(**kwargs):
token = request.headers["Authorization"].split("Bearer ")[1]
key_type, key = b64decode(token).decode("utf-8").split(":")
if requires_admin and key_type != "admin":
return jsonify(
{"error": True, "code": 2, "message": "insufficient permissions"}
)
g.wallet = await get_wallet_for_key(key, key_type)
if not g.wallet:
return jsonify(
{"error": True, "code": 2, "message": "insufficient permissions"}
)
return await view(**kwargs)
return wrapped_view
return wrap