Improved readability of privilege error messages
This commit is contained in:
parent
c60e8e1b9f
commit
231d6a732f
1 changed files with 5 additions and 5 deletions
|
@ -48,7 +48,7 @@ class PrivilegeService
|
||||||
public function assertPrivilege($privilege)
|
public function assertPrivilege($privilege)
|
||||||
{
|
{
|
||||||
if (!$this->hasPrivilege($privilege))
|
if (!$this->hasPrivilege($privilege))
|
||||||
$this->fail();
|
$this->fail($privilege);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function assertLoggedIn($userIdentifier = null)
|
public function assertLoggedIn($userIdentifier = null)
|
||||||
|
@ -56,12 +56,12 @@ class PrivilegeService
|
||||||
if ($userIdentifier)
|
if ($userIdentifier)
|
||||||
{
|
{
|
||||||
if (!$this->isLoggedIn($userIdentifier))
|
if (!$this->isLoggedIn($userIdentifier))
|
||||||
$this->fail();
|
$this->fail('not logged in');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!$this->authService->isLoggedIn())
|
if (!$this->authService->isLoggedIn())
|
||||||
$this->fail();
|
$this->fail('not logged in');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,8 +87,8 @@ class PrivilegeService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function fail()
|
private function fail($reason)
|
||||||
{
|
{
|
||||||
throw new \DomainException('Unprivileged operation');
|
throw new \DomainException('Unprivileged operation' . ($reason ? ' (' . $reason . ')' : ''));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue