| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentBoards\App\Http\Policies; |
| 4 |
|
| 5 |
use FluentBoards\App\Models\Board; |
| 6 |
use FluentBoards\App\Services\PublicAccessService; |
| 7 |
use FluentBoards\Framework\Http\Request\Request; |
| 8 |
|
| 9 |
class PublicBoardPolicy extends BasePolicy |
| 10 |
{ |
| 11 |
public function verifyRequest(Request $request) |
| 12 |
{ |
| 13 |
if (strtoupper($request->getMethod()) !== 'GET') { |
| 14 |
return false; |
| 15 |
} |
| 16 |
|
| 17 |
$boardId = absint($request->board_id); |
| 18 |
if (!$boardId) { |
| 19 |
return false; |
| 20 |
} |
| 21 |
|
| 22 |
$token = $request->getSafe('public_token', 'sanitize_text_field'); |
| 23 |
if (!PublicAccessService::validateAccessToken($boardId, $token)) { |
| 24 |
return false; |
| 25 |
} |
| 26 |
|
| 27 |
$board = Board::where('id', $boardId)->whereNull('archived_at')->first(); |
| 28 |
if (!$board) { |
| 29 |
return false; |
| 30 |
} |
| 31 |
|
| 32 |
return (bool)$board->getMetaByKey('public_access_enabled'); |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
|