hotfix
This commit is contained in:
+15
-4
@@ -26,13 +26,22 @@ def init_db(path: str) -> None:
|
||||
USERNAME TEXT NOT NULL UNIQUE,
|
||||
PWHASH TEXT NOT NULL,
|
||||
PWSALT TEXT NOT NULL,
|
||||
EMAIL TEXT
|
||||
EMAIL TEXT,
|
||||
IS_ADMIN INTEGER NOT NULL DEFAULT 0
|
||||
)
|
||||
''')
|
||||
|
||||
connection.commit()
|
||||
cursor.close()
|
||||
cursor.execute('''
|
||||
SELECT COUNT(*) FROM Users
|
||||
''')
|
||||
|
||||
if cursor.fetchone()[0] == 0:
|
||||
username = "root"
|
||||
password = urandom(8).hex()
|
||||
|
||||
create_user(path, username, password, is_admin=True)
|
||||
|
||||
print(f"No users detected, created new admin\nUser: {username}\nPass: {password}", flush=True)
|
||||
|
||||
def check_token_domain(db_path: str, token: str, domain: str) -> bool:
|
||||
with sqlite3.connect(db_path) as connection:
|
||||
@@ -287,7 +296,9 @@ def create_user(db_path: str, username: str, password: str, domains: list = [],
|
||||
cursor = connection.cursor()
|
||||
|
||||
username.strip()
|
||||
email.strip()
|
||||
|
||||
if email is not None:
|
||||
email.strip()
|
||||
|
||||
cursor.execute('''
|
||||
SELECT COUNT(*) FROM Users
|
||||
|
||||
+6
-6
@@ -1,11 +1,12 @@
|
||||
from flask import Flask, jsonify, request, render_template, redirect, session, flash
|
||||
import auth
|
||||
import re
|
||||
from os import environ, urandom
|
||||
|
||||
|
||||
|
||||
HOSTS_PATH = "/app/hosts.d/izbi"
|
||||
DB_PATH = "/app/sqlite.db"
|
||||
HOSTS_PATH = ( environ["HOSTS"] if "HOSTS" in environ else"/app/data/hosts.d/" ) + "/izbi"
|
||||
DB_PATH = environ["DB_PATH"] if "DB_PATH" in environ else "/app/data/sqlite.db"
|
||||
|
||||
|
||||
|
||||
@@ -14,12 +15,11 @@ app.config["SESSION_PERMANENT"] = True
|
||||
app.config["SESSION_TYPE"] = "memcached"
|
||||
app.config["PERMANENT_SESSION_LIFETIME"] = 3600
|
||||
|
||||
app.config["SECRET_KEY"] = "dsadasda"
|
||||
app.config["SECRET_KEY"] = environ["SECRET_KEY"] if "SECRET_KEY" in environ else urandom(32).hex()
|
||||
|
||||
hosts = {}
|
||||
|
||||
|
||||
|
||||
def update_hosts(path: str, hosts: dict = {}) -> bool:
|
||||
try:
|
||||
hosts_str = ""
|
||||
@@ -216,7 +216,7 @@ def change_password():
|
||||
|
||||
if "pass" not in request.form or "pass-new" not in request.form or "pass-rep" not in request.form:
|
||||
flash("password change failed")
|
||||
return reidrect("/dashboard")
|
||||
return redirect("/dashboard")
|
||||
if request.form["pass"] == "" or request.form["pass-new"] == "" or request.form["pass-rep"] == "":
|
||||
flash("password change failed")
|
||||
return redirect("/dashboard")
|
||||
@@ -281,4 +281,4 @@ def update_addr():
|
||||
|
||||
if __name__ == '__main__':
|
||||
auth.init_db(DB_PATH)
|
||||
app.run(host="0.0.0.0", port=8080, debug=True)
|
||||
app.run(host="0.0.0.0", port=8080, debug=False)
|
||||
|
||||
Reference in New Issue
Block a user