DikkiX / Schoolproject

BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

RBAC error when creating roles #3

Closed DikkiX closed 1 year ago

DikkiX commented 1 year ago

Hi maybe u have an idea,

I followed the rbac guide again and now have new problems. When creating an new Role and keeping the rule area empty, i get this error.

`PHP Warning – yii\base\ErrorException file_put_contents(C:\xampp\htdocs\Schoolproject\backend/rbac/items.php): Failed to open stream: No such file or directory

  1. in C:\xampp\htdocs\Schoolproject\vendor\yiisoft\yii2\rbac\PhpManager.phpat line 799 790791792793794795796797798799800801802803804805806807808 /**

    • Saves the authorization data to a PHP script file.
    • @param array $data the authorization data
    • @param string $file the file path.
    • @see loadFromFile() */ protected function saveToFile($data, $file) { file_put_contents($file, "<?php\n\nreturn " . VarDumper::export($data) . ";\n", LOCK_EX); $this->invalidateScriptCache($file); }

    /**

    • Invalidates precompiled script cache (such as OPCache or APC) for the given file.
    • @param string $file the file path.
    • @since 2.0.9 */ protected function invalidateScriptCache($file)`
image image
DikkiX commented 1 year ago

It never the nguide doesnt talk about any rbac item

DikkiX commented 1 year ago

@Cuji12

Cuji12 commented 1 year ago

Off the top of my head I'm not sure but I can see you've declared a components array twice in your common/config/main.php and your authManager twice - you should make sure there's no duplicates in that file, from the Yii2 RBAC docs: "In case of yii2-advanced-app the authManager should be declared only once in common/config/main.php."

Cuji12 commented 1 year ago

Also make sure you've ran your migrations for RBAC via "yii migrate --migrationPath=@yii/rbac/migrations".

Cuji12 commented 1 year ago

Looks like someone faced a similar issue here: https://forum.yiiframework.com/t/console-command-failed-solved/74195/12?page=2 which may help you too.

DikkiX commented 1 year ago

Off the top of my head I'm not sure but I can see you've declared a components array twice in your common/config/main.php and your authManager twice - you should make sure there's no duplicates in that file, from the Yii2 RBAC docs: "In case of yii2-advanced-app the authManager should be declared only once in common/config/main.php."

i cant see an duplicate in my config

DikkiX commented 1 year ago

So, i found the page that directs it.

image

but i changed it but now it shows this.

image

it should't say backend. u know a way to fix this?

DikkiX commented 1 year ago

fixed it!

Cuji12 commented 1 year ago

Haha nice one, assuming it was the issue where you were declaring RBAC - good luck with your project! On a side note, if you're interested in furthering your PHP education I'd recommend this book.

DikkiX commented 1 year ago

Haha nice one, assuming it was the issue where you were declaring RBAC - good luck with your project! On a side note, if you're interested in furthering your PHP education I'd recommend this book.

Yess, thanks i will check the book for sure i need it!!!

One last issue tho,

I just went thru everything and found a problem. When submitting in my form it does nothing, i dont even get an error just no response. u know this fix?? Its in my frontend view/overzicht

image