@@ -84,17 +84,14 @@ def upload_solution_get(hexidcrackme):
8484@limit ("20 per day" , key_func = lambda : session .get ('name' ))
8585def upload_solution_post (hexidcrackme ):
8686 """Handle solution file upload."""
87- _get_crackme_or_abort (hexidcrackme ) # Validate crackme exists
87+ crackme = _get_crackme_or_abort (hexidcrackme )
8888 username = session .get ('name' )
8989 redirect_url = f'/upload/solution/{ hexidcrackme } '
9090
9191 # Check if user already submitted a solution
92- try :
93- if solution_exists (username , hexidcrackme ):
94- flash ("You've already submitted a solution to this crackme" , FLASH_ERROR )
95- return redirect (redirect_url )
96- except ErrNoResult :
97- abort (404 )
92+ if solution_exists (username , crackme ['_id' ]):
93+ flash ("You've already submitted a solution to this crackme" , FLASH_ERROR )
94+ return redirect (redirect_url )
9895
9996 if not verify_recaptcha (request ):
10097 flash ('reCAPTCHA invalid!' , FLASH_ERROR )
@@ -198,17 +195,14 @@ def editor_solution_get(hexidcrackme):
198195@limit ("20 per day" , key_func = lambda : session .get ('name' ))
199196def editor_solution_post (hexidcrackme ):
200197 """Handle solution submission from the web editor."""
201- _get_crackme_or_abort (hexidcrackme ) # Validate crackme exists
198+ crackme = _get_crackme_or_abort (hexidcrackme )
202199 username = session .get ('name' )
203200 redirect_url = f'/upload/solution/{ hexidcrackme } /editor'
204201
205202 # Check if user already submitted a solution
206- try :
207- if solution_exists (username , hexidcrackme ):
208- flash ("You've already submitted a solution to this crackme" , FLASH_ERROR )
209- return redirect (redirect_url )
210- except ErrNoResult :
211- abort (404 )
203+ if solution_exists (username , crackme ['_id' ]):
204+ flash ("You've already submitted a solution to this crackme" , FLASH_ERROR )
205+ return redirect (redirect_url )
212206
213207 if not verify_recaptcha (request ):
214208 flash ('reCAPTCHA invalid!' , FLASH_ERROR )
0 commit comments