Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -92,16 +92,16 @@ def register():
|
|
92 |
email = data.get('email')
|
93 |
phone = data.get('phone')
|
94 |
|
95 |
-
#
|
96 |
-
phone = ''.join(e for e in phone if e.isalnum()) #
|
97 |
|
98 |
-
|
99 |
-
return jsonify({"success": False, "message": "All fields are required."}), 400
|
100 |
-
|
101 |
-
# Check if the phone number is exactly 10 digits
|
102 |
if len(phone) != 10:
|
103 |
return jsonify({"success": False, "message": "Phone number must be 10 digits."}), 400
|
104 |
|
|
|
|
|
|
|
105 |
try:
|
106 |
# Create a new record in Salesforce's Customer_Login__c object
|
107 |
customer_login = sf.Customer_Login__c.create({
|
@@ -123,10 +123,9 @@ def login():
|
|
123 |
login_email = data.get("email")
|
124 |
login_mobile = data.get("mobile")
|
125 |
|
126 |
-
#
|
127 |
login_mobile = ''.join(e for e in login_mobile if e.isalnum())
|
128 |
|
129 |
-
# Validate if email and mobile are present
|
130 |
if not login_email or not login_mobile:
|
131 |
return jsonify({"success": False, "message": "Missing email or mobile number"}), 400
|
132 |
|
@@ -143,6 +142,7 @@ def login():
|
|
143 |
except Exception as e:
|
144 |
return jsonify({"success": False, "message": "Internal server error", "error": str(e)}), 500
|
145 |
|
|
|
146 |
# Route to Get Menu Items
|
147 |
@app.route("/menu", methods=["GET"])
|
148 |
def menu_page():
|
|
|
92 |
email = data.get('email')
|
93 |
phone = data.get('phone')
|
94 |
|
95 |
+
# Clean phone number: remove unwanted characters (commas, spaces)
|
96 |
+
phone = ''.join(e for e in phone if e.isalnum()) # Keep only alphanumeric characters
|
97 |
|
98 |
+
# Validate phone number to ensure it's exactly 10 digits
|
|
|
|
|
|
|
99 |
if len(phone) != 10:
|
100 |
return jsonify({"success": False, "message": "Phone number must be 10 digits."}), 400
|
101 |
|
102 |
+
if not name or not email or not phone:
|
103 |
+
return jsonify({"success": False, "message": "All fields are required."}), 400
|
104 |
+
|
105 |
try:
|
106 |
# Create a new record in Salesforce's Customer_Login__c object
|
107 |
customer_login = sf.Customer_Login__c.create({
|
|
|
123 |
login_email = data.get("email")
|
124 |
login_mobile = data.get("mobile")
|
125 |
|
126 |
+
# Clean phone number: remove unwanted characters (commas, spaces)
|
127 |
login_mobile = ''.join(e for e in login_mobile if e.isalnum())
|
128 |
|
|
|
129 |
if not login_email or not login_mobile:
|
130 |
return jsonify({"success": False, "message": "Missing email or mobile number"}), 400
|
131 |
|
|
|
142 |
except Exception as e:
|
143 |
return jsonify({"success": False, "message": "Internal server error", "error": str(e)}), 500
|
144 |
|
145 |
+
|
146 |
# Route to Get Menu Items
|
147 |
@app.route("/menu", methods=["GET"])
|
148 |
def menu_page():
|