Skip to content
Permalink
Browse files
correctly handle non-existing username during permission testing
  • Loading branch information
Guite committed Sep 18, 2021
1 parent 38715a0 commit 1adc96eeb1211af65b0d81255a01a119bb27f65f
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/system/PermissionsModule/Controller/PermissionController.php
@@ -206,7 +206,7 @@ public function test(
$result = $this->trans('Permission check result:') . ' ';
if (!empty($data['user'])) {
$user = $userRepository->findOneBy(['uname' => $data['user']]);
$uid = isset($user) ? $user->getUid() : Constant::USER_ID_ANONYMOUS;
$uid = isset($user) ? $user->getUid() : false;
} else {
$uid = Constant::USER_ID_ANONYMOUS;
}
@@ -217,7 +217,7 @@ public function test(
$granted = $this->hasPermission($data['component'], $data['instance'], $data['level'], $uid);

$result .= '<span class="' . ($granted ? 'text-success' : 'text-danger') . '">';
$result .= (0 === $uid) ? $this->trans('unregistered user') : $data['user'];
$result .= Constant::USER_ID_ANONYMOUS < $uid && isset($user) ? $user->getUname() : $this->trans('unregistered user');
$result .= ': ';
if ($granted) {
$result .= $this->trans('permission granted.');

0 comments on commit 1adc96e

Please sign in to comment.