File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -66,14 +66,16 @@ public static function find()
66
66
67
67
if (self ::$ activeAccessTrait ) {
68
68
69
- // access owner check
70
- if ($ accessOwner ) {
69
+ // access owner check only if attribute exists and user is logged in
70
+ $ accessOwnerCheck = false ;
71
+ if ($ accessOwner && !\Yii::$ app ->user ->isGuest ) {
72
+ $ accessOwnerCheck = true ;
71
73
$ query ->where ([$ accessOwner => \Yii::$ app ->user ->id ]);
72
74
}
73
75
74
76
// access read check
75
77
if ($ accessRead ) {
76
- $ queryType = ($ accessOwner ) ? 'orWhere ' : 'where ' ;
78
+ $ queryType = ($ accessOwnerCheck ) ? 'orWhere ' : 'where ' ;
77
79
$ authItems = implode (', ' , array_keys (self ::getUsersAuthItems ()));
78
80
$ checkInSetQuery = self ::getInSetQueryPart ($ accessRead , $ authItems );
79
81
$ query ->$ queryType ($ checkInSetQuery );
You can’t perform that action at this time.
0 commit comments