From 41f2a74ed1deb6eb34c2f8c2a3de39145ff57744 Mon Sep 17 00:00:00 2001 From: arzumify Date: Tue, 14 May 2024 07:47:59 +0100 Subject: [PATCH] Various fixes --- config.ini | 4 ++-- main | 34 ++++------------------------------ templates/main.html | 5 ++--- templates/signup.html | 3 +++ 4 files changed, 11 insertions(+), 35 deletions(-) diff --git a/config.ini b/config.ini index fbb0956..b217e7f 100644 --- a/config.ini +++ b/config.ini @@ -1,6 +1,6 @@ [config] -PORT = 8080 -SECRET_KEY = placeholder +PORT = 8083 +SECRET_KEY = placeholdeqwoihqrqigriqukvfblisubgsierhueofbor UPLOAD_FOLDER = uploads PASSWORD_REQUIREMENT = 8 UPLOAD_LIMIT = 8 diff --git a/main b/main index a1d2c67..ec3e571 100644 --- a/main +++ b/main @@ -240,9 +240,9 @@ async def user(pageusername): if usersession: userCookie = get_session(usersession) user = get_user(userCookie["id"]) - return await render_template("user.html", userdata=user, createddate=datetime.datetime.utcfromtimestamp(int(str(pageuser["created"]).split(".")[0])).strftime("%Y-%m-%d"), pageuser=pageuser) + return await render_template("user.html", userdata=user, createddate=datetime.datetime.fromtimestamp(int(str(pageuser["created"]).split(".")[0])).strftime("%Y-%m-%d"), pageuser=pageuser) else: - return await render_template("user.html", createddate=datetime.datetime.utcfromtimestamp(int(str(pageuser["created"]).split(".")[0])).strftime("%Y-%m-%d"), pageuser=pageuser) + return await render_template("user.html", createddate=datetime.datetime.fromtimestamp(int(str(pageuser["created"]).split(".")[0])).strftime("%Y-%m-%d"), pageuser=pageuser) else: return """""", 404 @@ -553,39 +553,13 @@ async def cdn(filename): else: return "file doesn't exist!!" - @app.route("/signup", methods=("GET", "POST")) async def signup(): usersession = request.cookies.get("session_DO_NOT_SHARE") if usersession: return redirect(url_for("main")) - if request.method == "POST": - requestData = await request.form - - if not check_username_taken(requestData["username"]) == "error": - await flash("Username already taken :3") - return redirect(url_for("signup")) - - if not requestData["username"].isalnum(): - await flash("Username must be alphanumeric :3") - return redirect(url_for("signup")) - - if not len(requestData["password"]) > int(PASSWORD_REQUIREMENT): - await flash("Password must contain at least " + PASSWORD_REQUIREMENT + " characters") - return redirect(url_for("signup")) - - hashedpassword = generate_password_hash(requestData["password"]) - - conn = get_db_connection() - conn.execute("INSERT INTO users (username, password, created, htmldescription) VALUES (?, ?, ?, ?)", - (requestData["username"], hashedpassword, str(time.time()), "")) - conn.commit() - conn.close() - - return redirect(url_for("login")) else: - return await render_template("signup.html") - + return redirect(url_for("oauth")) @app.route("/login", methods=("GET", "POST")) async def login(): @@ -637,7 +611,7 @@ async def settings(): userCookie = get_session(usersession) user = get_user(userCookie["id"]) - return await render_template("settings.html", userdata=user, createddate=datetime.datetime.utcfromtimestamp(int(str(user["created"]).split(".")[0])).strftime("%Y-%m-%d %H:%m:%S")) + return await render_template("settings.html", userdata=user, createddate=datetime.datetime.fromtimestamp(int(str(user["created"]).split(".")[0])).strftime("%Y-%m-%d %H:%m:%S")) else: return redirect("/") diff --git a/templates/main.html b/templates/main.html index 8b89e0b..4eb779b 100644 --- a/templates/main.html +++ b/templates/main.html @@ -19,8 +19,7 @@ log out {{ userdata.username }} {% else %} - sign up - log in + login {% endif %} @@ -118,4 +117,4 @@ - \ No newline at end of file + diff --git a/templates/signup.html b/templates/signup.html index da2bea9..5548fd5 100644 --- a/templates/signup.html +++ b/templates/signup.html @@ -10,6 +10,9 @@ +

back