Skip to content

Commit

Permalink
Update auth_router.py
Browse files Browse the repository at this point in the history
  • Loading branch information
vineetshar committed Oct 30, 2024
1 parent db48a3a commit 6ecd9e6
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion app/modules/auth/auth_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
import requests
from dotenv import load_dotenv
from fastapi import Depends, Request
from fastapi.responses import Response
from fastapi.responses import JSONResponse, Response
from sqlalchemy.orm import Session

from app.core.database import get_db
from app.modules.auth.auth_schema import LoginRequest
from app.modules.users.user_schema import CreateUser
from app.modules.users.user_service import UserService
from app.modules.utils.APIRouter import APIRouter
from app.modules.utils.posthog_helper import PostHogClient
from app.modules.auth.auth_service import auth_handler

SLACK_WEBHOOK_URL = os.getenv("SLACK_WEBHOOK_URL", None)

Expand All @@ -27,6 +29,20 @@ async def send_slack_message(message: str):


class AuthAPI:

@auth_router.post("/login")
async def login(login_request: LoginRequest):
email, password = login_request.email, login_request.password

try:
res = auth_handler.login(email=email, password=password)
id_token = res.get("idToken")
return JSONResponse(content={"token": id_token}, status_code=200)
except Exception as e:
return JSONResponse(
content={"error": f"ERROR: {str(e)}"}, status_code=400
)

@auth_router.post("/signup")
async def signup(request: Request, db: Session = Depends(get_db)):
body = json.loads(await request.body())
Expand Down

0 comments on commit 6ecd9e6

Please sign in to comment.