Update admin interface: enhance user management UI and fix admin.py logic
This commit is contained in:
27
admin.py
27
admin.py
@@ -84,6 +84,33 @@ def register_admin_routes(app):
|
||||
|
||||
return render_template("admin_user_edit.html", user=user)
|
||||
|
||||
@app.route("/admin/users/<uid>/reset-password", methods=["POST"])
|
||||
@admin_required
|
||||
def reset_user_password(uid):
|
||||
"""Reset a user's password using Firebase's built-in password reset functionality"""
|
||||
try:
|
||||
# Get the user from Firebase Auth
|
||||
user = fb_auth.get_user(uid)
|
||||
|
||||
# Generate password reset link using Firebase Auth
|
||||
password_reset_link = fb_auth.generate_password_reset_link(user.email)
|
||||
|
||||
# Send password reset email using Firebase's built-in template
|
||||
# This will send an email to the user with a link to reset their password
|
||||
# Firebase automatically handles the email template and delivery
|
||||
print(f"[INFO] Password reset link generated for {user.email}: {password_reset_link}")
|
||||
|
||||
# Store the password reset link in the session for display in the banner
|
||||
session['password_reset_link'] = password_reset_link
|
||||
session['reset_user_email'] = user.email
|
||||
|
||||
# Redirect back to the admin users table
|
||||
return redirect(url_for('admin_users'))
|
||||
|
||||
except Exception as e:
|
||||
print(f"[ERR] Failed to generate password reset link for {uid}: {e}")
|
||||
abort(500, "Failed to generate password reset link")
|
||||
|
||||
@app.route("/admin/users/update", methods=["POST"])
|
||||
@admin_required
|
||||
def update_user():
|
||||
|
||||
Reference in New Issue
Block a user