From 0aeb662312772e2bd6d0003dc2e88e94ca6751e9 Mon Sep 17 00:00:00 2001 From: oguz ozturk Date: Mon, 12 Jan 2026 18:54:27 +0300 Subject: [PATCH] feat: Add customer password update endpoint for admin --- backend/app/routes/admin.py | 47 +++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/backend/app/routes/admin.py b/backend/app/routes/admin.py index 1ded2ce..54e6ce0 100644 --- a/backend/app/routes/admin.py +++ b/backend/app/routes/admin.py @@ -761,6 +761,53 @@ def update_customer_status(customer_id): }), 500 +@admin_bp.route('/customers//password', methods=['PUT']) +def update_customer_password(customer_id): + """Müşteri şifresini güncelle (Admin tarafından)""" + try: + data = request.json + new_password = data.get('new_password') + + if not new_password: + return jsonify({ + "status": "error", + "message": "Yeni şifre gerekli" + }), 400 + + # Şifre validasyonu + if len(new_password) < 8: + return jsonify({ + "status": "error", + "message": "Şifre en az 8 karakter olmalıdır" + }), 400 + + customer = Customer.query.get(customer_id) + + if not customer: + return jsonify({ + "status": "error", + "message": "Müşteri bulunamadı" + }), 404 + + user = User.query.get(customer.user_id) + + # Şifreyi güncelle + user.set_password(new_password) + db.session.commit() + + return jsonify({ + "status": "success", + "message": "Şifre başarıyla güncellendi" + }) + + except Exception as e: + db.session.rollback() + return jsonify({ + "status": "error", + "message": f"Şifre güncellenirken hata: {str(e)}" + }), 500 + + @admin_bp.route('/stats', methods=['GET']) def get_admin_stats(): """Admin dashboard istatistikleri"""