schmunk42 / yii2-giiant

Yii 2 Framework Code Generator Gii on Steroids
271 stars 120 forks source link

Giiant CRUD > Unknown Property – yii\base\UnknownPropertyException Getting, unknown property: common\models\User::isAdmin #89

Closed cloudswitch closed 8 years ago

cloudswitch commented 9 years ago

Hi,

after generating code with Giiant CRUD, I get this error message when trying to reach controller: Unknown Property – yii\base\UnknownPropertyException Getting, unknown property: common\models\User::isAdmin

When I comment this out: 'matchCallback' => function() use ($permission) { return \Yii::$app->user->can($permission) || (\Yii::$app->user->identity && \Yii::$app->user->identity->isAdmin); },

it seems to work. What is the problem here? Thx!

schmunk42 commented 9 years ago

The controllers depend on yii2-user at the moment. https://github.com/dektrium/yii2-rbac

Looks like we need a better more customizable solution for this. Eg. with auth item templates like in gtc (Yii1).

cloudswitch commented 9 years ago

no problem, I'm installing yii2-user also then. I just simply didn't know I need to install it also. Thanks a lot!

schmunk42 commented 9 years ago

Thanks for pointing this out.

cloudswitch commented 9 years ago

I've installed yii2-user, but it doesn't work jet so I can't check if giiant works or not.

schmunk42 commented 9 years ago

Uncomment the line in the template als a workaround.

Von meinem iPhone gesendet

Am 14.06.2015 um 19:56 schrieb cloudswitch notifications@github.com:

I've installed yii2-user, but it doesn't work jet so I can't check if giiant works or not.

— Reply to this email directly or view it on GitHub.

schmunk42 commented 9 years ago

Would this work better?

https://github.com/phundament/app/blob/feature/sprint-rc1/src/views/layouts/main.php#L53

cloudswitch commented 9 years ago

I have no clue, I'm not a professional, I don't understand what you mean, sorry.

thadudexx commented 9 years ago

how about replacing: 'matchCallback' => function($rule, $action) { return \Yii::$app->user->can(strtr($this->module->id, ['/' => '', '-' => ''])) || \Yii::$app->user->can(strtr($this->module->id . '/' . $this->id, ['/' => '', '-' => ''])) || \Yii::$app->user->can(strtr($this->module->id . '/' . $this->id . '/' . $action->id, ['/' => '', '-' => ''])) || (\Yii::$app->user->identity && \Yii::$app->user->identity->isAdmin); },

with: 'roles' => ['@']

wouldnt that be the easiest solution? At least if identityClass equals app\models\User.

schmunk42 commented 9 years ago

@deacix We need to review this, I also ran into problems with the auth items after the latest merges?!

schmunk42 commented 8 years ago

This should be fixed since a while.