Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HOTFIX: deal with no ergon register #257

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions app/routers/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ async def login_with_2fa(
# Validate access status in ERGON database
# ----------------------------------------
if user.is_ergon_validation_required:
is_active_employee = False
ergon_register = await read_bq(
f"""
SELECT *
Expand All @@ -136,8 +137,17 @@ async def login_with_2fa(
""",
from_file="/tmp/credentials.json",
)
# If has ERGON register and is an inactive employee: Unauthorized
if len(ergon_register) > 0 and ergon_register[0].get("status_ativo", False) is False:
# If has no ERGON register: Unauthorized
if len(ergon_register) == 0:
is_active_employee = False
# If has ERGON register and status_ativo is false: Unauthorized
elif ergon_register[0].get("status_ativo", False) is False:
is_active_employee = False
# If has ERGON register and status_ativo is true: Unauthorized
else:
is_active_employee = True

if not is_active_employee:
return JSONResponse(
status_code=401,
content={
Expand Down