|
@@ -12,7 +12,7 @@ import logging
|
|
|
from apps.web.models.users import UserModel, UserUpdateForm, UserRoleUpdateForm, Users
|
|
|
from apps.web.models.auths import Auths
|
|
|
|
|
|
-from utils.utils import get_current_user, get_password_hash, get_admin_user
|
|
|
+from utils.utils import get_verified_user, get_password_hash, get_admin_user
|
|
|
from constants import ERROR_MESSAGES
|
|
|
|
|
|
from config import SRC_LOG_LEVELS
|
|
@@ -67,6 +67,30 @@ async def update_user_role(form_data: UserRoleUpdateForm, user=Depends(get_admin
|
|
|
)
|
|
|
|
|
|
|
|
|
+############################
|
|
|
+# GetUserById
|
|
|
+############################
|
|
|
+
|
|
|
+
|
|
|
+class UserResponse(BaseModel):
|
|
|
+ name: str
|
|
|
+ profile_image_url: str
|
|
|
+
|
|
|
+
|
|
|
+@router.get("/{user_id}", response_model=UserResponse)
|
|
|
+async def get_user_by_id(user_id: str, user=Depends(get_verified_user)):
|
|
|
+
|
|
|
+ user = Users.get_user_by_id(user_id)
|
|
|
+
|
|
|
+ if user:
|
|
|
+ return UserResponse(name=user.name, profile_image_url=user.profile_image_url)
|
|
|
+ else:
|
|
|
+ raise HTTPException(
|
|
|
+ status_code=status.HTTP_400_BAD_REQUEST,
|
|
|
+ detail=ERROR_MESSAGES.USER_NOT_FOUND,
|
|
|
+ )
|
|
|
+
|
|
|
+
|
|
|
############################
|
|
|
# UpdateUserById
|
|
|
############################
|