feat: Add customer password update endpoint for admin
This commit is contained in:
parent
1fd9ad669c
commit
0aeb662312
|
|
@ -761,6 +761,53 @@ def update_customer_status(customer_id):
|
||||||
}), 500
|
}), 500
|
||||||
|
|
||||||
|
|
||||||
|
@admin_bp.route('/customers/<int:customer_id>/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'])
|
@admin_bp.route('/stats', methods=['GET'])
|
||||||
def get_admin_stats():
|
def get_admin_stats():
|
||||||
"""Admin dashboard istatistikleri"""
|
"""Admin dashboard istatistikleri"""
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue