Skip to content

Commit 633510c

Browse files
committed
fixed basepage check user permissions
1 parent 0c63fb8 commit 633510c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

app/base/abstracts/Controllers/BasePage.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
use \App\App;
2222
use \App\Site\Routing\RouteInfo;
2323
use \App\Site\Models\GuestUser;
24+
use \App\Site\Models\User;
25+
use \App\Base\Abstracts\Models\AccountModel;
2426

2527
/**
2628
* Base for all controllers
@@ -76,6 +78,10 @@ public function getCurrentUser()
7678
return $this->getContainer()->make(GuestUser::class);
7779
}
7880

81+
if ($this->current_user->id) {
82+
return $this->getContainer()->call([User::class, 'load'], ['id' => $this->current_user->id]);
83+
}
84+
7985
return $this->current_user;
8086
}
8187

@@ -118,7 +124,7 @@ public function renderPage(RouteInfo $route_info = null, $route_data = [])
118124
protected function checkPermission($permission_name)
119125
{
120126
try {
121-
return $this->getCurrentUser() && $this->getCurrentUser()->checkPermission($permission_name);
127+
return ($this->getCurrentUser() instanceof AccountModel) && $this->getCurrentUser()->checkPermission($permission_name);
122128
} catch (\Exception $e) {
123129
$this->getUtils()->logException($e);
124130
}

0 commit comments

Comments
 (0)