From 7edbd4e15b5e09957af17b6869ed3f6892d60508 Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Wed, 18 Dec 2024 01:43:28 -0500 Subject: [PATCH] fix reset start --- services/web/project/__init__.py | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/services/web/project/__init__.py b/services/web/project/__init__.py index 1b68989..03d4b66 100644 --- a/services/web/project/__init__.py +++ b/services/web/project/__init__.py @@ -254,7 +254,37 @@ def start_register(): @app.route("/panel/auth/reset", methods=["POST"]) def start_resetpass(): - return jsonify(hello="ameye world") + try: + data = request.json + if not data: + return { + "message": "Please provide username ", + "data": None, + "error": "Bad request" + }, 400 + # validate input + print(data) + is_validated = validate.validate_username(data.get('username')) + if is_validated is not True: + return dict(message='Invalid data', data=None, error=is_validated), 400 + + username= data.get('username') + sql = "INSERT INTO password_reset (username) VALUES (%s)" + val = (username) + with connection: + with connection.cursor() as cursor: + cursor.execute(sql, val) + connection.commit() + last_row_id=cursor.lastrowid + + return jsonify(hello="ameye reset path world", last_row_id=last_row_id) + + except Exception as e: + return { + "message": "Something went wrong!", + "error": str(e), + "data": None + }, 500 @app.route("/panel/account")