docs: Update task board and align development plan
This commit is contained in:
@@ -9,9 +9,10 @@ The goal is to create a service where streamers can log in using their platform
|
|||||||
## 2. Technology Stack
|
## 2. Technology Stack
|
||||||
|
|
||||||
* **Team Communications:** Discord and Nextcloud, primarily. This can change. There's a list of links in the [README.md](README.md)
|
* **Team Communications:** Discord and Nextcloud, primarily. This can change. There's a list of links in the [README.md](README.md)
|
||||||
* **Backend (API & Chat Listeners):** Python (for Twitch/YouTube chat listeners), Node.js (for WebSocket server and potentially other APIs), PHP (for user management and web serving).
|
* **Backend:** Python 3.9+ (FastAPI)
|
||||||
* **Database:** MySQL
|
* **Database:** SQLite (for initial development) with SQLAlchemy ORM
|
||||||
* **Frontend:** HTML, CSS, JavaScript
|
* **Frontend:** Vanilla HTML, CSS, and JavaScript
|
||||||
|
* **Chat Listeners:** `twitchio` (Twitch), `pytchat` (YouTube)
|
||||||
|
|
||||||
## 3. Implementation Roadmap
|
## 3. Implementation Roadmap
|
||||||
|
|
||||||
|
|||||||
26
auth.py
26
auth.py
@@ -79,13 +79,27 @@ async def auth_twitch_callback(code: str, state: str, request: Request, db: Sess
|
|||||||
user_response = await client.get(users_url, headers=headers)
|
user_response = await client.get(users_url, headers=headers)
|
||||||
user_data = user_response.json()["data"][0]
|
user_data = user_response.json()["data"][0]
|
||||||
|
|
||||||
# TODO: Upsert user into our database
|
|
||||||
# For now, we'll just return the user data as a proof of concept.
|
|
||||||
|
|
||||||
# Encrypt the tokens for storage
|
# Encrypt the tokens for storage
|
||||||
encrypted_tokens = security.encrypt_tokens(access_token, refresh_token)
|
encrypted_tokens = security.encrypt_tokens(access_token, refresh_token)
|
||||||
|
|
||||||
# Here you would create or update the user in your database
|
# --- Database Upsert Logic ---
|
||||||
# user = db.query(models.User).filter_by(platform_user_id=user_data['id']).first() ... etc.
|
# Check if the user already exists in our database
|
||||||
|
user = db.query(models.User).filter(models.User.platform_user_id == user_data['id']).first()
|
||||||
|
|
||||||
return {"message": "Twitch login successful!", "user": user_data, "encrypted_tokens": encrypted_tokens}
|
if user:
|
||||||
|
# If user exists, update their details
|
||||||
|
user.username = user_data['login']
|
||||||
|
user.encrypted_tokens = encrypted_tokens
|
||||||
|
else:
|
||||||
|
# If user does not exist, create a new record
|
||||||
|
user = models.User(
|
||||||
|
platform_user_id=user_data['id'],
|
||||||
|
username=user_data['login'],
|
||||||
|
platform="twitch",
|
||||||
|
encrypted_tokens=encrypted_tokens
|
||||||
|
)
|
||||||
|
db.add(user)
|
||||||
|
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
return {"message": f"Successfully authenticated as {user_data['display_name']}. User data has been saved."}
|
||||||
Reference in New Issue
Block a user