@@ -42,12 +42,10 @@ async def signup(
4242 db : Session = Depends (get_db ), user_data : UserCreate = Depends ()
4343) -> Any :
4444 try :
45- # async with db.begin_nested():
4645 user = await user_crud (transaction = True ).create (
4746 db = db ,
4847 user = user_data ,
4948 )
50- # raise Exception
5149 if user_data .tfa_enabled :
5250 device , qr_code = await device_crud (transaction = True ).create (
5351 db = db ,
@@ -78,6 +76,17 @@ async def signup(
7876 summary = "Create access and refresh tokens for user" ,
7977 status_code = status .HTTP_200_OK ,
8078 response_model = JwtTokenSchema | PreTfaJwtTokenSchema ,
79+ responses = {
80+ 200 : {
81+ "description" : "Credentials ok and TFA disabled" ,
82+ },
83+ 202 : {
84+ "description" : "Credentials ok and TFA enabled" ,
85+ },
86+ 401 : {
87+ "description" : "Invalid credentials" ,
88+ },
89+ }
8190)
8291async def login (
8392 response : Response ,
@@ -91,7 +100,7 @@ async def login(
91100 # wrong credentials
92101 if not user :
93102 raise HTTPException (
94- status_code = status .HTTP_400_BAD_REQUEST ,
103+ status_code = status .HTTP_401_UNAUTHORIZED ,
95104 detail = "Incorrect email or password" ,
96105 )
97106
@@ -115,7 +124,9 @@ async def login(
115124
116125
117126@auth_router .get (
118- "/test-token" , summary = "Test if the access token is ok" , response_model = UserOut
127+ "/test-token" ,
128+ summary = "Authenticated endpoint to test if access token is ok" ,
129+ response_model = UserOut
119130)
120131async def test_token (user : User = Depends (get_authenticated_user )):
121132 """
@@ -124,7 +135,11 @@ async def test_token(user: User = Depends(get_authenticated_user)):
124135 return user
125136
126137
127- @auth_router .post ("/refresh" , summary = "Refresh token" , response_model = JwtTokenSchema )
138+ @auth_router .post (
139+ "/refresh" ,
140+ summary = "Refresh token for elapsed access token" ,
141+ response_model = JwtTokenSchema
142+ )
128143async def refresh_token (
129144 db : Session = Depends (get_db ), refresh_token : str = Body (embed = True , title = 'refresh token' )
130145):
0 commit comments