| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentBoards\App\Http\Policies; |
| 4 |
|
| 5 |
use FluentBoards\App\Services\PermissionManager; |
| 6 |
use FluentBoards\Framework\Http\Request\Request; |
| 7 |
|
| 8 |
/** |
| 9 |
* AI assistant permissions. |
| 10 |
* |
| 11 |
* Managing AI settings (get/save/models/test) is admin-only. Generating text |
| 12 |
* is available to any authenticated Fluent Boards user, since it is used from |
| 13 |
* the task description editor. |
| 14 |
*/ |
| 15 |
class AiPolicy extends BasePolicy |
| 16 |
{ |
| 17 |
/** |
| 18 |
* Default guard for AI settings routes. |
| 19 |
*/ |
| 20 |
public function verifyRequest(Request $request) |
| 21 |
{ |
| 22 |
return PermissionManager::isAdmin(); |
| 23 |
} |
| 24 |
|
| 25 |
/** |
| 26 |
* Text generation is allowed for Fluent Boards users (admins or board members). |
| 27 |
* |
| 28 |
* Deliberately stricter than a plain logged-in check: this endpoint accepts an |
| 29 |
* arbitrary prompt and spends the site owner's AI credits on every call, so a |
| 30 |
* WP user with no board access must not be able to use it as a free AI proxy. |
| 31 |
*/ |
| 32 |
public function generate(Request $request) |
| 33 |
{ |
| 34 |
return PermissionManager::userHasAnyBoardAccess(); |
| 35 |
} |
| 36 |
} |
| 37 |
|