From f4a758677189cd312ef0d31f9937f68df6150dfd Mon Sep 17 00:00:00 2001 From: arzumify Date: Sun, 25 Feb 2024 17:05:55 +0000 Subject: [PATCH] Migration to chacha2 start --- main | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/main b/main index 1a044fe..adcd807 100644 --- a/main +++ b/main @@ -178,6 +178,12 @@ def apilogin(): username = data["username"] password = data["password"] + usernames_old = ['EXAMPLE'] + + migrate = false + if username in usernames_old: + migrate = true + check_username_thing = check_username_taken(username) if check_username_thing == "error": @@ -197,9 +203,28 @@ def apilogin(): conn.commit() conn.close() - return { - "key": randomCharacters - }, 200 + if migrate = false: + return { + "key": randomCharacters + }, 200 + else: + return { + "key": randomCharacters, + "migrate": "1" + }, 200 + +@app.route("/api/supersecretapi", methods=("GET", "POST")) +def apilogin(): + if request.method == "POST": + data = request.get_json() + username = data["username"] + password = data["password"] + hashedpassword = generate_password_hash(password) + + conn = get_db_connection() + conn.execute("UPDATE users SET password = ? WHERE username = ?", (hashedpassword, username)) + conn.commit() + conn.close() @app.route("/api/userinfo", methods=("GET", "POST")) def apiuserinfo():