Spaces:
Sleeping
Sleeping
fix: revert city field on user profile (catalogue prices shown to all users)
Browse files
main.py
CHANGED
|
@@ -592,26 +592,13 @@ def update_user_profile():
|
|
| 592 |
uid = verify_token(request.headers.get('Authorization'))
|
| 593 |
if not uid:
|
| 594 |
return jsonify({'error': 'Invalid or expired token'}), 401
|
| 595 |
-
data = request.get_json()
|
| 596 |
new_display_name = data.get('displayName')
|
| 597 |
-
|
| 598 |
-
|
| 599 |
-
updates = {}
|
| 600 |
-
if new_display_name is not None:
|
| 601 |
-
if not isinstance(new_display_name, str) or len(new_display_name.strip()) == 0:
|
| 602 |
-
return jsonify({'error': 'A valid displayName is required.'}), 400
|
| 603 |
-
updates['displayName'] = new_display_name
|
| 604 |
-
if new_city is not None:
|
| 605 |
-
if new_city not in SUPPORTED_CITIES:
|
| 606 |
-
return jsonify({'error': f'city must be one of: {", ".join(SUPPORTED_CITIES)}'}), 400
|
| 607 |
-
updates['city'] = new_city
|
| 608 |
-
if not updates:
|
| 609 |
-
return jsonify({'error': 'Provide displayName and/or city to update.'}), 400
|
| 610 |
-
|
| 611 |
try:
|
| 612 |
-
|
| 613 |
-
|
| 614 |
-
db_ref.child(f'users/{uid}').update(updates)
|
| 615 |
return jsonify({'success': True, 'message': 'Profile updated successfully.'}), 200
|
| 616 |
except Exception as e:
|
| 617 |
logger.error(f"Error updating profile for user {uid}: {e}")
|
|
|
|
| 592 |
uid = verify_token(request.headers.get('Authorization'))
|
| 593 |
if not uid:
|
| 594 |
return jsonify({'error': 'Invalid or expired token'}), 401
|
| 595 |
+
data = request.get_json()
|
| 596 |
new_display_name = data.get('displayName')
|
| 597 |
+
if not new_display_name or not isinstance(new_display_name, str) or len(new_display_name.strip()) == 0:
|
| 598 |
+
return jsonify({'error': 'A valid displayName is required.'}), 400
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 599 |
try:
|
| 600 |
+
auth.update_user(uid, display_name=new_display_name)
|
| 601 |
+
db_ref.child(f'users/{uid}').update({'displayName': new_display_name})
|
|
|
|
| 602 |
return jsonify({'success': True, 'message': 'Profile updated successfully.'}), 200
|
| 603 |
except Exception as e:
|
| 604 |
logger.error(f"Error updating profile for user {uid}: {e}")
|