feat: user soft delete
This commit is contained in:
parent
5b98be9787
commit
a9e059bf0a
1 changed files with 4 additions and 2 deletions
|
|
@ -7,6 +7,7 @@ Endpoints:
|
|||
- [GET](/user/): [super admin]: Returns user(id) details.
|
||||
- [DELETE](/user/): [super admin]: Removes a User(id) from the hub database.
|
||||
"""
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from fastapi import APIRouter, status, BackgroundTasks
|
||||
|
||||
|
|
@ -104,7 +105,7 @@ async def get_user_by_id(
|
|||
status.HTTP_404_NOT_FOUND: {"description": "User not found"},
|
||||
},
|
||||
)
|
||||
async def delete_user_by_id(
|
||||
async def soft_delete_user_by_id(
|
||||
db: DbSession,
|
||||
user_model: user_model_query_dependency,
|
||||
su: super_admin_dependency,
|
||||
|
|
@ -112,7 +113,8 @@ async def delete_user_by_id(
|
|||
"""
|
||||
Deletes the user with the provided ID from the database. This will not remove them from OIDC, and they will be automatically readded on next login.
|
||||
"""
|
||||
db.delete(user_model)
|
||||
user_model.active = False
|
||||
user_model.deleted_at = datetime.now(tz=timezone.utc)
|
||||
db.commit()
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue