toggle status instead
Browse files- App/Users/UserRoutes.py +3 -3
App/Users/UserRoutes.py
CHANGED
@@ -132,11 +132,11 @@ async def delete_user(user_id: str):
|
|
132 |
|
133 |
|
134 |
@user_router.put(
|
135 |
-
"/user/
|
136 |
response_model=BaseResponse,
|
137 |
status_code=status.HTTP_200_OK,
|
138 |
)
|
139 |
-
async def
|
140 |
user = await User.filter(id=user_id).first()
|
141 |
if not user:
|
142 |
raise HTTPException(
|
@@ -146,6 +146,6 @@ async def disable_user(user_id: str):
|
|
146 |
raise HTTPException(
|
147 |
status_code=status.HTTP_400_BAD_REQUEST, detail="User is already disabled."
|
148 |
)
|
149 |
-
user.account_locked =
|
150 |
await user.save()
|
151 |
return BaseResponse(code=200, message="User disabled successfully.")
|
|
|
132 |
|
133 |
|
134 |
@user_router.put(
|
135 |
+
"/user/toggle_status/{user_id}",
|
136 |
response_model=BaseResponse,
|
137 |
status_code=status.HTTP_200_OK,
|
138 |
)
|
139 |
+
async def toggle_user_status(user_id: str):
|
140 |
user = await User.filter(id=user_id).first()
|
141 |
if not user:
|
142 |
raise HTTPException(
|
|
|
146 |
raise HTTPException(
|
147 |
status_code=status.HTTP_400_BAD_REQUEST, detail="User is already disabled."
|
148 |
)
|
149 |
+
user.account_locked = not user.account_locked
|
150 |
await user.save()
|
151 |
return BaseResponse(code=200, message="User disabled successfully.")
|