From 279c7df9b96a387f6f5617997b4c4bdb585b9a96 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Tue, 20 Aug 2019 17:18:18 +0200 Subject: [PATCH] Document permission check methods --- src/User/AssertPermissionTrait.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/User/AssertPermissionTrait.php b/src/User/AssertPermissionTrait.php index 8941b1615..2ba07ee87 100644 --- a/src/User/AssertPermissionTrait.php +++ b/src/User/AssertPermissionTrait.php @@ -17,6 +17,13 @@ use Flarum\User\Exception\PermissionDeniedException; trait AssertPermissionTrait { /** + * Ensure the current user is allowed to do something. + * + * If the condition is not met, an exception will be thrown that signals the + * lack of permissions. This is about *authorization*, i.e. retrying such a + * request / operation without a change in permissions (or using another + * user account) is pointless. + * * @param bool $condition * @throws PermissionDeniedException */ @@ -28,6 +35,12 @@ trait AssertPermissionTrait } /** + * Ensure the current user is authenticated. + * + * This will throw an exception for guest users, signaling that + * *authorization* failed. Thus, they could retry the operation after + * logging in (or using other means of authentication). + * * @param bool $condition * @throws NotAuthenticatedException */