From 9b4c996cc97a51f87352941154ac566e8177720a Mon Sep 17 00:00:00 2001 From: mpyw Date: Fri, 8 Jun 2018 23:44:12 +0900 Subject: [PATCH 1/2] Add GuardHelpers::alreadyAuthenticated() It behave similarly to `GuardHelpers::check()`, but it doesn't trigger any side effects. --- GuardHelpers.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/GuardHelpers.php b/GuardHelpers.php index 9a682c3dc..2bb632ff7 100644 --- a/GuardHelpers.php +++ b/GuardHelpers.php @@ -40,6 +40,16 @@ public function authenticate() throw new AuthenticationException; } + /** + * Determine if the current user is already authenticated without triggering side effects. + * + * @return bool + */ + public function alreadyAuthenticated() + { + return ! is_null($this->user); + } + /** * Determine if the current user is authenticated. * From f6972a57f9d80375a0a94ac40a7eff9861398cb5 Mon Sep 17 00:00:00 2001 From: mpyw Date: Sat, 9 Jun 2018 02:32:19 +0900 Subject: [PATCH 2/2] Rename GuardHelpers::alreadyAuthenticated() to GuardHelpers::hasUser() --- GuardHelpers.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GuardHelpers.php b/GuardHelpers.php index 2bb632ff7..291c65d46 100644 --- a/GuardHelpers.php +++ b/GuardHelpers.php @@ -41,11 +41,11 @@ public function authenticate() } /** - * Determine if the current user is already authenticated without triggering side effects. + * Determine if the guard has the current user without triggering side effects. * * @return bool */ - public function alreadyAuthenticated() + public function hasUser() { return ! is_null($this->user); }