-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth_handler.py
More file actions
23 lines (20 loc) · 861 Bytes
/
auth_handler.py
File metadata and controls
23 lines (20 loc) · 861 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import streamlit as st
import firebase_admin
from firebase_admin import auth, credentials
# Ensure Firebase is initialized once
if not firebase_admin._apps:
cred = credentials.Certificate("serviceAccountKey.json")
firebase_admin.initialize_app(cred)
def register_user(email, password):
"""Registers a new user with Firebase Authentication."""
try:
user = auth.create_user(email=email, password=password)
st.success(f"Account created for {email}")
return user
except Exception as e:
st.error(f"Error: {e}")
def login_user(email, password):
"""Simulates login (Firebase Admin SDK can't verify passwords directly)."""
st.warning("⚠️ Login password check requires Firebase Client SDK.")
st.info("For now, enter your email and we’ll use it to separate your data.")
return {"email": email}