Skip to content

Commit b177d73

Browse files
committed
input validation
1 parent f1ef461 commit b177d73

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

api/v1/auth/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ async def validate_otp(
325325
hackatime_data = None
326326
try:
327327
hackatime_data = get_account(otp_client_response.email)
328-
except Exception as e: # type: ignore # pylint: disable=broad-exception-caught
328+
except Exception: # type: ignore # pylint: disable=broad-exception-caught
329329
pass # unable to fetch hackatime data, continue anyway
330330
user = User(
331331
email=otp_client_response.email,

api/v1/projects/main.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,11 @@ async def link_hackatime_project(
219219
"""Link a Hackatime project to a user project"""
220220
user_email = request.state.user["sub"]
221221

222+
if hackatime_project.name == "":
223+
raise HTTPException(
224+
status_code=400, detail="Hackatime project name cannot be empty"
225+
)
226+
222227
project_raw = await session.execute(
223228
sqlalchemy.select(UserProject).where(
224229
UserProject.id == project_id, UserProject.user_email == user_email
@@ -285,6 +290,11 @@ async def unlink_hackatime_project(
285290
"""Unlink a Hackatime project from a user project"""
286291
user_email = request.state.user["sub"]
287292

293+
if hackatime_project.name == "":
294+
raise HTTPException(
295+
status_code=400, detail="Hackatime project name cannot be empty"
296+
)
297+
288298
project_raw = await session.execute(
289299
sqlalchemy.select(UserProject).where(
290300
UserProject.id == project_id, UserProject.user_email == user_email

0 commit comments

Comments
 (0)