Spaces:
Sleeping
Sleeping
Create demo.py
Browse files
demo.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Add test account creation function
|
| 2 |
+
def create_test_accounts():
|
| 3 |
+
try:
|
| 4 |
+
# Create/admin2@test.com (Admin)
|
| 5 |
+
try:
|
| 6 |
+
admin_user = auth.create_user(
|
| 7 |
+
email='admin2@test.com',
|
| 8 |
+
password='password1'
|
| 9 |
+
)
|
| 10 |
+
except auth.EmailAlreadyExistsError:
|
| 11 |
+
admin_user = auth.get_user_by_email('admin2@test.com')
|
| 12 |
+
|
| 13 |
+
db.reference(f'users/{admin_user.uid}').set({
|
| 14 |
+
'daily_cash': 300,
|
| 15 |
+
'remaining_cash': 300,
|
| 16 |
+
'last_reset': '2000-01-01T00:00:00+00:00',
|
| 17 |
+
'is_admin': True
|
| 18 |
+
})
|
| 19 |
+
|
| 20 |
+
# Create user1@test.com (Regular user)
|
| 21 |
+
try:
|
| 22 |
+
regular_user = auth.create_user(
|
| 23 |
+
email='user1@test.com',
|
| 24 |
+
password='123456'
|
| 25 |
+
)
|
| 26 |
+
except auth.EmailAlreadyExistsError:
|
| 27 |
+
regular_user = auth.get_user_by_email('user1@test.com')
|
| 28 |
+
|
| 29 |
+
db.reference(f'users/{regular_user.uid}').set({
|
| 30 |
+
'daily_cash': 300,
|
| 31 |
+
'remaining_cash': 300,
|
| 32 |
+
'last_reset': '2000-01-01T00:00:00+00:00',
|
| 33 |
+
'is_admin': False
|
| 34 |
+
})
|
| 35 |
+
|
| 36 |
+
print("Test accounts created/updated successfully")
|
| 37 |
+
except Exception as e:
|
| 38 |
+
print(f"Error creating test accounts: {str(e)}")
|
| 39 |
+
|
| 40 |
+
# Create test accounts when server starts
|
| 41 |
+
create_test_accounts()
|