Skip to content

Commit

Permalink
Add users/me endpoint
Browse files Browse the repository at this point in the history
It will be used to get more information about the current user
  • Loading branch information
anarute committed Oct 10, 2023
1 parent 621cc30 commit 3150753
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion api/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from routers.v1 import projects, timelog
from routers.v1 import projects, timelog, users

from db.db_connection import engine
from db.base_class import Base
Expand Down Expand Up @@ -30,6 +30,7 @@

app.include_router(projects.router, prefix="/v1")
app.include_router(timelog.router, prefix="/v1")
app.include_router(users.router, prefix="/v1")


@app.get("/")
Expand Down
19 changes: 19 additions & 0 deletions api/routers/v1/users.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from fastapi import APIRouter, Depends
from sqlalchemy.orm import Session

from db.db_connection import get_db
from auth.auth_bearer import BearerToken
from dependencies import get_current_user
from schemas.user import AppUser

router = APIRouter(
prefix="/users",
tags=["users"],
responses={403: {"description": "Forbidden"}, 404: {"description": "Not found"}},
dependencies=[Depends(BearerToken())],
)


@router.get("/users/me", response_model=AppUser)
async def get_current_user_profile(current_user=Depends(get_current_user), db: Session = Depends(get_db)):
return current_user

0 comments on commit 3150753

Please sign in to comment.