Skip to content

Commit e9ade42

Browse files
author
rob
committed
thow exception when middleware blocks the request
1 parent 258be5f commit e9ade42

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

src/Abstracts/Middleware.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ public function respond($response, $data = [])
156156
return Redirect::to($redirect);
157157
}
158158

159+
if ($exception = $response['exception']) {
160+
throw new $exception();
161+
}
162+
159163
if ($response['abort']) {
160164
abort($response['code'], trans('firewall::responses.block.message'));
161165
}

src/Config/firewall.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
'redirect' => env('FIREWALL_BLOCK_REDIRECT', null),
2020
'abort' => env('FIREWALL_BLOCK_ABORT', false),
2121
'code' => env('FIREWALL_BLOCK_CODE', 403),
22+
'exception' => \Akaunting\Firewall\Exceptions\FirewallBlockedException::class,
2223
],
2324

2425
],
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Akaunting\Firewall\Exceptions;
4+
5+
use Exception;
6+
7+
class FirewallBlockedException extends Exception
8+
{
9+
10+
}

0 commit comments

Comments
 (0)