Updated audit log such that if user is deleted, empty string is passed as username

This commit is contained in:
Saurab-Shrestha 2024-02-27 12:32:25 +05:45
parent 484b6b7223
commit 46c4a3122b
4 changed files with 11 additions and 4 deletions

View File

@ -44,7 +44,7 @@ def create_app(root_injector: Injector) -> FastAPI:
allow_credentials=True,
allow_origins=["http://localhost:80/", "http://10.1.101.125:80", "http://quickgpt.gibl.com.np:80", "http://127.0.0.1",
"http://10.1.101.125", "http://quickgpt.gibl.com.np", "http://localhost:8001", "http://192.168.1.93", "http://192.168.1.93:88",
"http://192.168.1.98", "http://192.168.1.98:5173", "http://localhost:5173", "http://127.0.0.1/", "http://localhost/",
"http://192.168.1.98", "http://192.168.1.98:5173", "http://localhost:3000","https://globaldocquery.gibl.com.np/", "http://127.0.0.1/", "http://localhost/",
"http://localhost:80", "http://192.168.1.131:80/", "http://192.168.1.131"],
allow_methods=["DELETE", "GET", "POST", "PUT", "OPTIONS", "PATCH"],
allow_headers=["*"],

View File

@ -26,12 +26,18 @@ def list_companies(
"""
Retrieve a list of companies with pagination support.
"""
def get_fullname(id):
user = crud.user.get_by_id(db, id=id)
if user:
return user.fullname
return ""
logs = crud.audit.get_multi_desc(db, skip=skip, limit=limit)
logs = [
schemas.Audit(
id=dep.id,
model=dep.model,
username=(crud.user.get_by_id(db, id=dep.user_id).fullname),
username=get_fullname(dep.user_id),
details=dep.details,
action=dep.action,
timestamp=dep.timestamp,

View File

@ -131,10 +131,11 @@ def login_access_token(
else:
username, department = ldap_login(db=db, username=form_data.username, password=form_data.password)
depart = crud.department.get_by_department_name(db, name=department)
if depart:
ad_user_register(db=db, email=form_data.username, fullname=username, password=form_data.password, department_id=depart.id)
else:
department_in = schemas.DepartmentCreate(name=depart)
department_in = schemas.DepartmentCreate(name=department)
new_department = crud.department.create(db, obj_in=department_in)
ad_user_register(db=db, email=form_data.username, fullname=username, password=form_data.password, department_id=new_department.id)
return True

View File

@ -3,7 +3,7 @@
# Syntax in `private_pgt/settings/settings.py`
server:
env_name: ${APP_ENV:prod}
port: ${PORT:88}
port: ${PORT:8000}
cors:
enabled: true
allow_credentials: true