Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1515,23 +1515,104 @@ def handle_signin(phone, password):
|
|
1515 |
"""Handle user sign in"""
|
1516 |
try:
|
1517 |
if not phone or not password:
|
1518 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1519 |
|
1520 |
if not validate_phone_number(phone):
|
1521 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1522 |
|
1523 |
user_name = db.authenticate_user(phone, password)
|
1524 |
|
1525 |
if not user_name:
|
1526 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1527 |
|
1528 |
# Return successful login with dashboard data
|
1529 |
dashboard_data = show_dashboard(phone, user_name)
|
1530 |
-
return
|
1531 |
|
1532 |
except Exception as e:
|
1533 |
logger.error(f"Sign in error: {e}")
|
1534 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1535 |
|
1536 |
def handle_signup(name, phone, password, confirm_password):
|
1537 |
"""Handle user registration"""
|
|
|
1515 |
"""Handle user sign in"""
|
1516 |
try:
|
1517 |
if not phone or not password:
|
1518 |
+
# Return 32 values: status + 18 dashboard components + 13 more outputs
|
1519 |
+
return (
|
1520 |
+
"β Please fill all fields", # signin_status
|
1521 |
+
gr.update(), # landing_page
|
1522 |
+
gr.update(), # signin_page
|
1523 |
+
gr.update(), # signup_page
|
1524 |
+
gr.update(), # dashboard_page
|
1525 |
+
gr.update(), # welcome_message
|
1526 |
+
gr.update(), # balance_display
|
1527 |
+
gr.update(), # current_user
|
1528 |
+
gr.update(), # income
|
1529 |
+
gr.update(), # savings_goal
|
1530 |
+
*[gr.update() for _ in range(14)], # allocation_inputs (14 categories)
|
1531 |
+
gr.update(), # expense_table
|
1532 |
+
gr.update(), # investments_table
|
1533 |
+
gr.update(), # spending_log_table
|
1534 |
+
gr.update(), # spending_chart
|
1535 |
+
gr.update(), # balance_chart
|
1536 |
+
gr.update(), # family_info
|
1537 |
+
gr.update(), # family_members
|
1538 |
+
gr.update() # receipts_table
|
1539 |
+
)
|
1540 |
|
1541 |
if not validate_phone_number(phone):
|
1542 |
+
return (
|
1543 |
+
"β Invalid phone format. Use +92XXXXXXXXXX", # signin_status
|
1544 |
+
gr.update(), # landing_page
|
1545 |
+
gr.update(), # signin_page
|
1546 |
+
gr.update(), # signup_page
|
1547 |
+
gr.update(), # dashboard_page
|
1548 |
+
gr.update(), # welcome_message
|
1549 |
+
gr.update(), # balance_display
|
1550 |
+
gr.update(), # current_user
|
1551 |
+
gr.update(), # income
|
1552 |
+
gr.update(), # savings_goal
|
1553 |
+
*[gr.update() for _ in range(14)], # allocation_inputs (14 categories)
|
1554 |
+
gr.update(), # expense_table
|
1555 |
+
gr.update(), # investments_table
|
1556 |
+
gr.update(), # spending_log_table
|
1557 |
+
gr.update(), # spending_chart
|
1558 |
+
gr.update(), # balance_chart
|
1559 |
+
gr.update(), # family_info
|
1560 |
+
gr.update(), # family_members
|
1561 |
+
gr.update() # receipts_table
|
1562 |
+
)
|
1563 |
|
1564 |
user_name = db.authenticate_user(phone, password)
|
1565 |
|
1566 |
if not user_name:
|
1567 |
+
return (
|
1568 |
+
"β Invalid phone number or password", # signin_status
|
1569 |
+
gr.update(), # landing_page
|
1570 |
+
gr.update(), # signin_page
|
1571 |
+
gr.update(), # signup_page
|
1572 |
+
gr.update(), # dashboard_page
|
1573 |
+
gr.update(), # welcome_message
|
1574 |
+
gr.update(), # balance_display
|
1575 |
+
gr.update(), # current_user
|
1576 |
+
gr.update(), # income
|
1577 |
+
gr.update(), # savings_goal
|
1578 |
+
*[gr.update() for _ in range(14)], # allocation_inputs (14 categories)
|
1579 |
+
gr.update(), # expense_table
|
1580 |
+
gr.update(), # investments_table
|
1581 |
+
gr.update(), # spending_log_table
|
1582 |
+
gr.update(), # spending_chart
|
1583 |
+
gr.update(), # balance_chart
|
1584 |
+
gr.update(), # family_info
|
1585 |
+
gr.update(), # family_members
|
1586 |
+
gr.update() # receipts_table
|
1587 |
+
)
|
1588 |
|
1589 |
# Return successful login with dashboard data
|
1590 |
dashboard_data = show_dashboard(phone, user_name)
|
1591 |
+
return (f"β
Signed in as {user_name}",) + tuple(dashboard_data)
|
1592 |
|
1593 |
except Exception as e:
|
1594 |
logger.error(f"Sign in error: {e}")
|
1595 |
+
return (
|
1596 |
+
f"β Sign in failed: {str(e)}", # signin_status
|
1597 |
+
gr.update(), # landing_page
|
1598 |
+
gr.update(), # signin_page
|
1599 |
+
gr.update(), # signup_page
|
1600 |
+
gr.update(), # dashboard_page
|
1601 |
+
gr.update(), # welcome_message
|
1602 |
+
gr.update(), # balance_display
|
1603 |
+
gr.update(), # current_user
|
1604 |
+
gr.update(), # income
|
1605 |
+
gr.update(), # savings_goal
|
1606 |
+
*[gr.update() for _ in range(14)], # allocation_inputs (14 categories)
|
1607 |
+
gr.update(), # expense_table
|
1608 |
+
gr.update(), # investments_table
|
1609 |
+
gr.update(), # spending_log_table
|
1610 |
+
gr.update(), # spending_chart
|
1611 |
+
gr.update(), # balance_chart
|
1612 |
+
gr.update(), # family_info
|
1613 |
+
gr.update(), # family_members
|
1614 |
+
gr.update() # receipts_table
|
1615 |
+
)
|
1616 |
|
1617 |
def handle_signup(name, phone, password, confirm_password):
|
1618 |
"""Handle user registration"""
|