"
- content += ""
+ content += f""
content += ""
content += ""
return render_template("message.html", account=account,
-
title="xPub Key",
- content=""+xpub+"" + content)
+ content=f"{xpub}{content}")
return redirect("/settings?error=Invalid action")
@@ -1214,6 +1222,9 @@ def upload_image():
return redirect("/login?message=Not logged in")
account = request.cookies.get("account")
+ account = account_module.check_account(account)
+ if not account:
+ return redirect("/logout")
if not os.path.exists('user_data/images'):
os.mkdir('user_data/images')
@@ -1223,11 +1234,12 @@ def upload_image():
file = request.files['image']
if file.filename == '':
return redirect("/settings?error=No file selected")
- if file:
- filepath = os.path.join(f'user_data/images/{account.split(":")[0]}.{file.filename.split(".")[-1]}')
+ if file and file.filename:
+ filepath = os.path.join(f'user_data/images/{account}.{file.filename.split(".")[-1]}')
file.save(filepath)
return redirect("/settings?success=File uploaded successfully")
+ return redirect("/settings?error=An error occurred")
def latestVersion(branch):
result = requests.get(f"https://git.woodburn.au/api/v1/repos/nathanwoodburn/firewalletbrowser/branches")
@@ -1264,6 +1276,12 @@ def login_post():
account = request.form.get("account")
password = request.form.get("password")
+ if account == None or password == None:
+ wallets = account_module.listWallets()
+ wallets = render.wallets(wallets)
+ return render_template("login.html",
+ error="Invalid account or password",wallets=wallets)
+
# Check if the account is valid
if account.count(":") > 0:
wallets = account_module.listWallets()
@@ -1279,8 +1297,6 @@ def login_post():
wallets = render.wallets(wallets)
return render_template("login.html",
error="Invalid account or password",wallets=wallets)
-
-
# Set the cookie
response = make_response(redirect("/"))
response.set_cookie("account", account)
@@ -1299,6 +1315,11 @@ def register():
password = request.form.get("password")
repeatPassword = request.form.get("password_repeat")
+ if account == None or password == None or repeatPassword == None:
+ return render_template("register.html",
+ error="Invalid account or password",
+ name=account,password=password,password_repeat=repeatPassword)
+
# Check if the passwords match
if password != repeatPassword:
return render_template("register.html",
@@ -1328,10 +1349,8 @@ def register():
# Set the cookie
- response = make_response(render_template("message.html",
-
- title="Account Created",
- content="Your account has been created. Here is your seed phrase. Please write it down and keep it safe as it will not be shown again
" + response['seed']))
+ response = make_response(render_template("message.html",title="Account Created",
+ content=f"Your account has been created. Here is your seed phrase. Please write it down and keep it safe as it will not be shown again
{response['seed']}"))
response.set_cookie("account", account+":"+password)
return response
@@ -1343,6 +1362,12 @@ def import_wallet():
repeatPassword = request.form.get("password_repeat")
seed = request.form.get("seed")
+ if account == None or password == None or repeatPassword == None or seed == None:
+ return render_template("import-wallet.html",
+ error="Invalid account, password or seed",
+ name=account,password=password,password_repeat=repeatPassword,
+ seed=seed)
+
# Check if the passwords match
if password != repeatPassword:
return render_template("import-wallet.html",
@@ -1559,6 +1584,7 @@ def api_hsd(function):
stats = domainInfo['info']['stats'] if 'stats' in domainInfo['info'] else {}
state = domainInfo['info']['state']
next_action = ""
+ next = ""
if state == 'CLOSED':
if not domainInfo['info']['registered']:
if account_module.isOwnDomain(account,domain):
@@ -1637,7 +1663,10 @@ def api_wallet(function):
return jsonify({"error": "Not logged in"})
account = account_module.check_account(request.cookies.get("account"))
- password = request.cookies.get("account").split(":")[1]
+ if not account:
+ return jsonify({"error": "Invalid account"})
+
+ password = request.cookies.get("account","").split(":")[1]
if not account:
return jsonify({"error": "Invalid account"})
@@ -1671,7 +1700,7 @@ def api_wallet(function):
if function == "domains":
domains = account_module.getDomains(account)
- if 'error' in domains:
+ if type(domains) == dict and 'error' in domains:
return jsonify({"result": [], "error": domains['error']})
# Add nameRender to each domain
@@ -1682,7 +1711,7 @@ def api_wallet(function):
if function == "transactions":
# Get the page parameter
- page = request.args.get('page')
+ page = request.args.get('page', 1)
try:
page = int(page)
except:
@@ -1758,7 +1787,7 @@ def api_wallet_mobile(function):
return jsonify({"error": "Not logged in"})
account = account_module.check_account(request.cookies.get("account"))
- password = request.cookies.get("account").split(":")[1]
+ password = request.cookies.get("account","").split(":")[1]
if not account:
return jsonify({"error": "Invalid account"})
@@ -1820,7 +1849,11 @@ def renderDomain(name: str) -> str:
#region Assets and default pages
@app.route('/qr/')
def qr(data):
- return send_file(qrcode(data, mode="raw"), mimetype="image/png")
+
+ output = qrcode(data, mode="raw")
+ if output is None:
+ return jsonify({"error": "Invalid data"}), 400
+ return send_file(output, mimetype="image/png")
# Theme
@app.route('/assets/css/styles.min.css')
diff --git a/plugin.py b/plugin.py
index b162a6e..374ceed 100644
--- a/plugin.py
+++ b/plugin.py
@@ -152,7 +152,10 @@ def getPluginFunctions(plugin: str):
return plugin.functions
-def runPluginFunction(plugin: str, function: str, params: dict, authentication: str):
+def runPluginFunction(plugin: str, function: str, params: dict, authentication: (str|None)):
+ if not authentication:
+ return {"error": "Authentication required"}
+
plugin_module = import_module(plugin.replace("/","."))
if function not in plugin_module.functions:
return {"error": "Function not found"}