Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -29,43 +29,7 @@ bucket = storage.bucket()
|
|
| 29 |
api_key = os.environ['Gemini']
|
| 30 |
|
| 31 |
|
| 32 |
-
def initialize_admin():
|
| 33 |
-
# Initialize Firebase Admin SDK
|
| 34 |
-
cred = credentials.Certificate('mydateproject-e7994-firebase-adminsdk-mpa9a-2fd9c32a98.json')
|
| 35 |
-
firebase_admin.initialize_app(cred, {
|
| 36 |
-
'databaseURL': 'your-database-url'
|
| 37 |
-
})
|
| 38 |
|
| 39 |
-
try:
|
| 40 |
-
# Create admin user in Firebase Auth
|
| 41 |
-
admin_email = "admin1@test.com" # Change this
|
| 42 |
-
admin_password = "admin123" # Change this
|
| 43 |
-
|
| 44 |
-
# Create the user
|
| 45 |
-
admin_user = auth.create_user(
|
| 46 |
-
email=admin_email,
|
| 47 |
-
password=admin_password
|
| 48 |
-
)
|
| 49 |
-
|
| 50 |
-
# Set admin custom claim
|
| 51 |
-
auth.set_custom_user_claims(admin_user.uid, {'admin': True})
|
| 52 |
-
|
| 53 |
-
# Create admin data in Realtime Database
|
| 54 |
-
admin_ref = db.reference(f'users/{admin_user.uid}')
|
| 55 |
-
admin_ref.set({
|
| 56 |
-
'email': admin_email,
|
| 57 |
-
'daily_cash': 0.0, # Admins typically don't need petty cash
|
| 58 |
-
'remaining_cash': 0.0,
|
| 59 |
-
'last_reset': datetime.now(pytz.UTC).isoformat(),
|
| 60 |
-
'is_admin': True
|
| 61 |
-
})
|
| 62 |
-
|
| 63 |
-
print(f"Admin account created successfully!")
|
| 64 |
-
print(f"Email: {admin_email}")
|
| 65 |
-
print(f"UID: {admin_user.uid}")
|
| 66 |
-
|
| 67 |
-
except Exception as e:
|
| 68 |
-
print(f"Error creating admin account: {str(e)}")
|
| 69 |
|
| 70 |
# admin create user.
|
| 71 |
@app.route('/api/admin/create-user', methods=['POST'])
|
|
@@ -370,5 +334,4 @@ def get_all_transactions():
|
|
| 370 |
return jsonify({'error': str(e)}), 500
|
| 371 |
|
| 372 |
if __name__ == '__main__':
|
| 373 |
-
initialize_admin()
|
| 374 |
app.run(debug=True, host="0.0.0.0", port=7860)
|
|
|
|
| 29 |
api_key = os.environ['Gemini']
|
| 30 |
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
# admin create user.
|
| 35 |
@app.route('/api/admin/create-user', methods=['POST'])
|
|
|
|
| 334 |
return jsonify({'error': str(e)}), 500
|
| 335 |
|
| 336 |
if __name__ == '__main__':
|
|
|
|
| 337 |
app.run(debug=True, host="0.0.0.0", port=7860)
|