Skip to content

Commit

Permalink
fix(core): initial
Browse files Browse the repository at this point in the history
  • Loading branch information
hsbmaulana committed Jan 7, 2024
1 parent 81861ea commit d1a2787
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tripteki/laravelphp-acl",
"version": "1.1.5",
"version": "1.1.8",
"description": "Trip Teknologi's Laravel.php ACLs",

"readme": "README.md",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function up()

app("cache")->store(config("permission.cache.store") != "default" ? config("permission.cache.store") : null)->forget(config("permission.cache.key"));

$this->role->rule(ACLServiceProvider::SUPERUSER);
$this->role->rule(ACLServiceProvider::$SUPERADMIN);
}

/**
Expand Down
11 changes: 8 additions & 3 deletions src/Providers/ACLServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ class ACLServiceProvider extends ServiceProvider
/**
* @var string
*/
public const SUPERUSER = "superuser";
public static $SUPERADMIN = "superadmin";

/**
* @var string
*/
public static $SUPERUSER = "superuser";

/**
* @var bool
Expand Down Expand Up @@ -98,12 +103,12 @@ protected function registerSuperuser()
{
Gate::before(function ($user, $ability) {

return $user->hasRole(ACLServiceProvider::SUPERUSER) ? true : null;
return $user->hasRole(ACLServiceProvider::$SUPERADMIN) ? true : null;
});

// Gate::after(function ($user, $ability) { //

// return $user->hasRole(ACLServiceProvider::SUPERUSER); //
// return $user->hasRole(ACLServiceProvider::$SUPERADMIN); //
// }); //
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function all($querystring = [])

$content = QueryBuilder::for(app(PermissionModel::class)->query());

if (! Auth::check() || ! Auth::user()->hasRole(ACLServiceProvider::SUPERUSER)) {
if (! Auth::check() || ! Auth::user()->hasRole(ACLServiceProvider::$SUPERADMIN)) {

$content = $content->whereNot("name", "like", "%models%");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function authorize()
*/
public function rules()
{
$ownable = Auth::check() && Auth::user()->hasRole(ACLServiceProvider::SUPERUSER) ? "|" : "|not_regex:/models/|";
$ownable = Auth::check() && Auth::user()->hasRole(ACLServiceProvider::$SUPERADMIN) ? "|" : "|not_regex:/models/|";

return [

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function authorize()
*/
public function rules()
{
$ownable = Auth::check() && Auth::user()->hasRole(ACLServiceProvider::SUPERUSER) ? "|" : "|not_regex:/models/|";
$ownable = Auth::check() && Auth::user()->hasRole(ACLServiceProvider::$SUPERADMIN) ? "|" : "|not_regex:/models/|";

return [

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function rules()
{
return [

"role" => "required|string|not_regex:/^".ACLServiceProvider::SUPERUSER."$/|exists:".config("permission.models.role").",name",
"role" => "required|string|not_regex:/^".ACLServiceProvider::$SUPERADMIN."$/|exists:".config("permission.models.role").",name",
];
}
};

0 comments on commit d1a2787

Please sign in to comment.