Skip to content

Commit

Permalink
Fix Vulnerability While Saving Coupon
Browse files Browse the repository at this point in the history
  • Loading branch information
Blair2004 committed Sep 30, 2021
1 parent 5242ac9 commit e347d74
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/Crud/CouponCrud.php
Expand Up @@ -164,6 +164,7 @@ public function getForm( $entry = null )
'type' => 'text',
'name' => 'code',
'label' => __( 'Coupon Code' ),
'validation' => 'required',
'description' => __( 'Might be used while printing the coupon.' ),
'value' => $entry->code ?? '',
], [
Expand Down
5 changes: 4 additions & 1 deletion app/Exceptions/Handler.php
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Auth\AuthenticationException;
use Illuminate\Database\QueryException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Support\Facades\Log;
use Illuminate\Validation\ValidationException as MainValidationException;
use Throwable;

Expand Down Expand Up @@ -77,8 +78,10 @@ public function render($request, Throwable $exception)

if ( $exception instanceof QueryException ) {
if ( $request->expectsJson() ) {
Log::error( $exception->getMessage() );

return response()->json([
'message' => $exception->getMessage()
'message' => env( 'APP_DEBUG' ) ? $exception->getMessage() : __( 'A database error has occured.' )
], 404);
}

Expand Down

0 comments on commit e347d74

Please sign in to comment.