diff --git a/frontends/web/app.py b/frontends/web/app.py index b0da964..9e450b9 100644 --- a/frontends/web/app.py +++ b/frontends/web/app.py @@ -1552,9 +1552,17 @@ def admin_user_new(): password = request.form.get("password", "") success, message, user = create_user(username, password) + + # Check if AJAX request + if request.headers.get("X-Requested-With") == "XMLHttpRequest": + if success: + return jsonify({"success": True, "username": username, "password": password}) + else: + return jsonify({"success": False, "error": message}) + + # Regular form submission fallback if success: flash(f"User '{username}' created successfully", "success") - # Store password temporarily for display session["temp_password"] = password session["temp_username"] = username return redirect(url_for("admin_user_created")) diff --git a/frontends/web/templates/admin/user_new.html b/frontends/web/templates/admin/user_new.html index 84da57d..905bc3f 100644 --- a/frontends/web/templates/admin/user_new.html +++ b/frontends/web/templates/admin/user_new.html @@ -11,12 +11,12 @@ Add New User
-
+
-
+
+
- @@ -57,8 +59,108 @@
+ + + {% endblock %} {% block scripts %} + {% endblock %} diff --git a/frontends/web/templates/base.html b/frontends/web/templates/base.html index d096f9e..7408ad7 100644 --- a/frontends/web/templates/base.html +++ b/frontends/web/templates/base.html @@ -67,16 +67,18 @@
{% with messages = get_flashed_messages(with_categories=true) %} {% if messages %} - {% for category, message in messages %} - - {% endfor %} +
+ {% for category, message in messages %} + + {% endfor %} +
{% endif %} {% endwith %} - + {% block content %}{% endblock %}