summaryrefslogtreecommitdiffstats
path: root/Core
diff options
context:
space:
mode:
Diffstat (limited to 'Core')
-rw-r--r--Core/SecurityContext.php14
-rw-r--r--Core/SecurityContextInterface.php9
2 files changed, 23 insertions, 0 deletions
diff --git a/Core/SecurityContext.php b/Core/SecurityContext.php
index 6d11850..fc39407 100644
--- a/Core/SecurityContext.php
+++ b/Core/SecurityContext.php
@@ -89,4 +89,18 @@ class SecurityContext implements SecurityContextInterface
{
$this->token = $token;
}
+
+ /**
+ * Returns the current user, if one exists.
+ *
+ * @return mixed Returns either an object which implements __toString(),
+ * or a primitive string if there is a token, otherwise
+ * returns null.
+ */
+ public function getUser()
+ {
+ if ($this->token) {
+ return $this->token->getUser();
+ }
+ }
}
diff --git a/Core/SecurityContextInterface.php b/Core/SecurityContextInterface.php
index d0c7214..600f7b4 100644
--- a/Core/SecurityContextInterface.php
+++ b/Core/SecurityContextInterface.php
@@ -39,6 +39,15 @@ interface SecurityContextInterface
function setToken(TokenInterface $token = null);
/**
+ * Returns the current user, if one exists.
+ *
+ * @return mixed Returns either an object which implements __toString(),
+ * or a primitive string if there is a token, otherwise
+ * returns null.
+ */
+ function getUser();
+
+ /**
* Checks if the attributes are granted against the current authentication token and optionally supplied object.
*
* @param array $attributes