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"""