Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
fix some minor security issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mytja committed Oct 6, 2023
1 parent a1bb114 commit b51c82e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,11 @@ async def get_timetable(response: Response, date: str | None, authorization: str
if len(days) == 0:
raise Exception("len(days) is 0")
except Exception as e:
print(f"[TIMETABLE] GimSIS login failed: {e}")
response.status_code = status.HTTP_403_FORBIDDEN
return {
"type": "gimsis_login_fail",
"data": "GimSIS login failed",
"error": str(e),
}

print(f"[INFO] Parsing timetable for user {account_session.username}")
Expand Down
5 changes: 0 additions & 5 deletions src/endpoints/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ async def login(response: Response, username: str = Form(), password: str = Form
"type": "reg_fail",
"data": "GimSIS session verification failed",
"session": None,
"error": str(e),
}

try:
Expand All @@ -84,7 +83,6 @@ async def login(response: Response, username: str = Form(), password: str = Form
"type": "reg_fail",
"data": "Password hashing failed. Aborted.",
"session": None,
"error": str(e),
}

try:
Expand All @@ -96,7 +94,6 @@ async def login(response: Response, username: str = Form(), password: str = Form
"type": "reg_fail",
"data": "Password encryption failed. Aborted.",
"session": None,
"error": str(e),
}

user = User(
Expand Down Expand Up @@ -133,7 +130,6 @@ async def login(response: Response, username: str = Form(), password: str = Form
"type": "login_fail",
"data": "Session login failed.",
"session": None,
"error": str(e),
}

break
Expand Down Expand Up @@ -167,7 +163,6 @@ async def login(response: Response, username: str = Form(), password: str = Form
"type": "login_fail",
"data": "Could not decrypt GimSIS password.",
"session": None,
"error": str(e),
}

try:
Expand Down
8 changes: 4 additions & 4 deletions src/endpoints/lopolisweb.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ async def get_meals(response: Response, month: str, year: str, authorization: st
await account_session.login()
menus = await account_session.lopolis_session.get_menus(year, month)
except Exception as e:
print(f"[LOPOLIS] Error while authorizing {account_session.username} with an error {e}")
response.status_code = status.HTTP_403_FORBIDDEN
return {
"error": e,
"data": "Not authorized using Lo.Polis",
}

Expand All @@ -61,9 +61,9 @@ async def set_meals(response: Response, month: str, year: str, authorization: st
await account_session.login()
menus = await account_session.lopolis_session.set_menus(year, month, json.loads(lopolis_response))
except Exception as e:
print(f"[LOPOLIS] Error while authorizing {account_session.username} with an error {e}")
response.status_code = status.HTTP_403_FORBIDDEN
return {
"error": e,
"data": "Not authorized using Lo.Polis",
}

Expand All @@ -90,9 +90,9 @@ async def get_checkouts(response: Response, month: str, year: str, authorization
await account_session.login()
checkouts = await account_session.lopolis_session.get_checkouts(year, month)
except Exception as e:
print(f"[LOPOLIS] Error while authorizing {account_session.username} with an error {e}")
response.status_code = status.HTTP_403_FORBIDDEN
return {
"error": e,
"data": "Not authorized using Lo.Polis",
}

Expand All @@ -119,9 +119,9 @@ async def set_checkouts(response: Response, month: str, year: str, authorization
await account_session.login()
checkouts = await account_session.lopolis_session.set_checkouts(year, month, json.loads(lopolis_response))
except Exception as e:
print(f"[LOPOLIS] Error while authorizing {account_session.username} with an error {e}")
response.status_code = status.HTTP_403_FORBIDDEN
return {
"error": e,
"data": "Not authorized using Lo.Polis",
}

Expand Down

0 comments on commit b51c82e

Please sign in to comment.