diff --git a/backend/app/Models/Permission.php b/backend/app/Models/Permission.php index 1a88ee8..5a1319f 100644 --- a/backend/app/Models/Permission.php +++ b/backend/app/Models/Permission.php @@ -2,9 +2,8 @@ namespace App\Models; -use Laratrust\Models\LaratrustPermission; +use Laratrust\Models\Permission as PermissionModel; -class Permission extends LaratrustPermission +class Permission extends PermissionModel { - public $guarded = []; -} +} \ No newline at end of file diff --git a/backend/app/Models/Role.php b/backend/app/Models/Role.php index 6e9144c..5c04f51 100644 --- a/backend/app/Models/Role.php +++ b/backend/app/Models/Role.php @@ -2,9 +2,8 @@ namespace App\Models; -use Laratrust\Models\LaratrustRole; +use Laratrust\Models\Role as RoleModel; -class Role extends LaratrustRole +class Role extends RoleModel { - public $guarded = []; } diff --git a/backend/app/Models/User.php b/backend/app/Models/User.php index 3f9e4be..3abae2a 100644 --- a/backend/app/Models/User.php +++ b/backend/app/Models/User.php @@ -7,12 +7,13 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; use Laravel\Sanctum\HasApiTokens; -use Laratrust\Traits\LaratrustUserTrait; +use Laratrust\Contracts\LaratrustUser; +use Laratrust\Traits\HasRolesAndPermissions; use Lab404\Impersonate\Models\Impersonate; -class User extends Authenticatable +class User extends Authenticatable implements LaratrustUser { - use LaratrustUserTrait; + use HasRolesAndPermissions; use Impersonate; use HasApiTokens, HasFactory, Notifiable; diff --git a/backend/composer.lock b/backend/composer.lock index 99da0ac..df1802a 100644 --- a/backend/composer.lock +++ b/backend/composer.lock @@ -3714,16 +3714,16 @@ }, { "name": "psy/psysh", - "version": "v0.11.20", + "version": "v0.11.22", "source": { "type": "git", "url": "https://github.com/bobthecow/psysh.git", - "reference": "0fa27040553d1d280a67a4393194df5228afea5b" + "reference": "128fa1b608be651999ed9789c95e6e2a31b5802b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/bobthecow/psysh/zipball/0fa27040553d1d280a67a4393194df5228afea5b", - "reference": "0fa27040553d1d280a67a4393194df5228afea5b", + "url": "https://api.github.com/repos/bobthecow/psysh/zipball/128fa1b608be651999ed9789c95e6e2a31b5802b", + "reference": "128fa1b608be651999ed9789c95e6e2a31b5802b", "shasum": "" }, "require": { @@ -3752,7 +3752,11 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "0.11.x-dev" + "dev-0.11": "0.11.x-dev" + }, + "bamarni-bin": { + "bin-links": false, + "forward-command": false } }, "autoload": { @@ -3784,9 +3788,9 @@ ], "support": { "issues": "https://github.com/bobthecow/psysh/issues", - "source": "https://github.com/bobthecow/psysh/tree/v0.11.20" + "source": "https://github.com/bobthecow/psysh/tree/v0.11.22" }, - "time": "2023-07-31T14:32:22+00:00" + "time": "2023-10-14T21:56:36+00:00" }, { "name": "ralouphie/getallheaders", @@ -9693,5 +9697,5 @@ "php": "^8.1" }, "platform-dev": [], - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.3.0" } diff --git a/backend/config/laratrust.php b/backend/config/laratrust.php index a3ff0d5..f545f2a 100644 --- a/backend/config/laratrust.php +++ b/backend/config/laratrust.php @@ -14,18 +14,44 @@ return [ /* |-------------------------------------------------------------------------- - | Which permissions and role checker to use. + | Checkers |-------------------------------------------------------------------------- | - | Defines if you want to use the roles and permissions checker. - | Available: - | - default: Check for the roles and permissions using the method that Laratrust - has always used. - | - query: Check for the roles and permissions using direct queries to the database. - | This method doesn't support cache yet. + | Manage Laratrust's role and permissions checkers configurations. | - */ - 'checker' => 'default', + */ + 'checkers' => [ + + /* + |-------------------------------------------------------------------------- + | Which permissions checker to use. + |-------------------------------------------------------------------------- + | + | Defines if you want to use the roles and permissions checker. + | Available: + | - default: Check for the roles and permissions using the method that Laratrust + | has always used. + | - query: Check for the roles and permissions using direct queries to the database. + | This method doesn't support cache yet. + | - class that extends Laratrust\Checkers\User\UserChecker + */ + 'user' => 'default', + + /* + |-------------------------------------------------------------------------- + | Which role checker to use. + |-------------------------------------------------------------------------- + | + | Defines if you want to use the roles and permissions checker. + | Available: + | - default: Check for the roles and permissions using the method that Laratrust + has always used. + | - query: Check for the roles and permissions using direct queries to the database. + | This method doesn't support cache yet. + | - class that extends Laratrust\Checkers\Role\RoleChecker + */ + 'role' => 'default', + ], /* |-------------------------------------------------------------------------- @@ -67,7 +93,7 @@ return [ | This is the array that contains the information of the user models. | This information is used in the add-trait command, for the roles and | permissions relationships with the possible user models, and the - | administration panel to attach roles and permissions to the users. + | administration panel to add roles and permissions to the users. | | The key in the array is the name of the relationship inside the roles and permissions. | @@ -164,13 +190,13 @@ return [ */ 'middleware' => [ /** - * Define if the laratrust middleware are registered automatically in the service provider + * Define if the laratrust middleware are registered automatically in the service provider. */ 'register' => true, /** * Method to be called in the middleware return case. - * Available: abort|redirect + * Available: abort|redirect. */ 'handling' => 'abort', @@ -180,11 +206,11 @@ return [ */ 'handlers' => [ /** - * Aborts the execution with a 403 code and allows you to provide the response text + * Aborts the execution with a 403 code and allows you to provide the response text. */ 'abort' => [ 'code' => 403, - 'message' => 'User does not have any of the necessary access rights.' + 'message' => 'User does not have any of the necessary access rights.', ], /** @@ -197,10 +223,10 @@ return [ 'url' => '/home', 'message' => [ 'key' => 'error', - 'content' => '' - ] - ] - ] + 'content' => '', + ], + ], + ], ], 'teams' => [ @@ -220,26 +246,14 @@ return [ | Strict check for roles/permissions inside teams |-------------------------------------------------------------------------- | - | Determines if a strict check should be done when checking if a role or permission - | is attached inside a team. + | Determines if a strict check should be done when checking if a role or permission is added inside a team. | If it's false, when checking a role/permission without specifying the team, - | it will check only if the user has attached that role/permission ignoring the team. + | it will check only if the user has added that role/permission ignoring the team. | */ 'strict_check' => false, ], - /* - |-------------------------------------------------------------------------- - | Laratrust Magic 'isAbleTo' Method - |-------------------------------------------------------------------------- - | - | Supported cases for the magic is able to method (Refer to the docs). - | Available: camel_case|snake_case|kebab_case - | - */ - 'magic_is_able_to_method_case' => 'kebab_case', - /* |-------------------------------------------------------------------------- | Laratrust Permissions as Gates @@ -270,6 +284,17 @@ return [ */ 'register' => false, + /* + |-------------------------------------------------------------------------- + | Laratrust Panel Domain + |-------------------------------------------------------------------------- + | + | This is the Domain Laratrust panel for roles and permissions + | will be accessible from. + | + */ + 'domain' => env('LARATRUST_PANEL_DOMAIN'), + /* |-------------------------------------------------------------------------- | Laratrust Panel Path @@ -296,7 +321,7 @@ return [ | Laratrust Panel Route Middleware |-------------------------------------------------------------------------- | - | These middleware will get attached onto each Laratrust panel route. + | These middleware will get added onto each Laratrust panel route. | */ 'middleware' => ['api'], @@ -340,5 +365,5 @@ return [ // The user won't be able to delete the role. 'not_deletable' => [], ], - ] + ], ];