@@ -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 )
@@ -188,17 +185,14 @@ def editor_solution_get(hexidcrackme):
188185@limit ("20 per day" , key_func = lambda : session .get ('name' ))
189186def editor_solution_post (hexidcrackme ):
190187 """Handle solution submission from the web editor."""
191- _get_crackme_or_abort (hexidcrackme ) # Validate crackme exists
188+ crackme = _get_crackme_or_abort (hexidcrackme )
192189 username = session .get ('name' )
193190 redirect_url = f'/upload/solution/{ hexidcrackme } /editor'
194191
195192 # Check if user already submitted a solution
196- try :
197- if solution_exists (username , hexidcrackme ):
198- flash ("You've already submitted a solution to this crackme" , FLASH_ERROR )
199- return redirect (redirect_url )
200- except ErrNoResult :
201- abort (404 )
193+ if solution_exists (username , crackme ['_id' ]):
194+ flash ("You've already submitted a solution to this crackme" , FLASH_ERROR )
195+ return redirect (redirect_url )
202196
203197 if not verify_recaptcha (request ):
204198 flash ('reCAPTCHA invalid!' , FLASH_ERROR )
0 commit comments