1010
1111import database
1212from auth import crud
13- from auth .models import LoginBodyParams , SiteUserModel
13+ from auth .models import LoginBodyParams , SiteUserModel , UpdateUserParams
1414from constants import DOMAIN , IS_PROD , SAMESITE
1515from utils .shared_models import DetailModel , MessageModel
1616
@@ -134,15 +134,16 @@ async def get_user(
134134 """
135135 session_id = request .cookies .get ("session_id" , None )
136136 if session_id is None :
137- raise HTTPException (status_code = 401 , detail = "User must be authenticated to get their info" )
137+ raise HTTPException (status_code = 401 , detail = "user must be authenticated to get their info" )
138138
139139 user_info = await crud .get_site_user (db_session , session_id )
140140 if user_info is None :
141- raise HTTPException (status_code = 401 , detail = "Could not find user with session_id, please log in" )
141+ raise HTTPException (status_code = 401 , detail = "could not find user with session_id, please log in" )
142142
143143 return JSONResponse (user_info .serialize ())
144144
145145
146+ # TODO: We should change this so that the admins can change people's pictures too, so they can remove offensive stuff
146147@router .patch (
147148 "/user" ,
148149 operation_id = "update_user" ,
@@ -153,18 +154,18 @@ async def get_user(
153154 },
154155)
155156async def update_user (
156- profile_picture_url : str ,
157+ body : UpdateUserParams ,
157158 request : Request ,
158159 db_session : database .DBSession ,
159160):
160161 """
161162 Returns the info stored in the site_user table in the auth module, if the user is logged in.
162163 """
163- session_id = request .cookies .get ("session_id" , None )
164+ session_id = request .cookies .get ("session_id" )
164165 if session_id is None :
165- raise HTTPException (status_code = 401 , detail = "User must be authenticated to get their info" )
166+ raise HTTPException (status_code = 401 , detail = "user must be authenticated to get their info" )
166167
167- ok = await crud .update_site_user (db_session , session_id , profile_picture_url )
168+ ok = await crud .update_site_user (db_session , session_id , body . profile_picture_url )
168169 await db_session .commit ()
169170 if not ok :
170- raise HTTPException (status_code = 401 , detail = "Could not find user with session_id, please log in" )
171+ raise HTTPException (status_code = 401 , detail = "could not find user with session_id, please log in" )
0 commit comments