summaryrefslogtreecommitdiffstats
path: root/Guard/AbstractGuardAuthenticator.php
diff options
context:
space:
mode:
Diffstat (limited to 'Guard/AbstractGuardAuthenticator.php')
-rw-r--r--Guard/AbstractGuardAuthenticator.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/Guard/AbstractGuardAuthenticator.php b/Guard/AbstractGuardAuthenticator.php
new file mode 100644
index 0000000..ebd09bb
--- /dev/null
+++ b/Guard/AbstractGuardAuthenticator.php
@@ -0,0 +1,31 @@
+<?php
+
+namespace Symfony\Component\Security\Guard;
+
+use Symfony\Component\Security\Core\User\UserInterface;
+use Symfony\Component\Security\Guard\Token\GenericGuardToken;
+
+/**
+ * An optional base class that creates a GenericGuardToken for you
+ *
+ * @author Ryan Weaver <weaverryan@gmail.com>
+ */
+abstract class AbstractGuardAuthenticator implements GuardAuthenticatorInterface
+{
+ /**
+ * Shortcut to create a GenericGuardToken for you, if you don't really
+ * care about which authenticated token you're using
+ *
+ * @param UserInterface $user
+ * @param string $providerKey
+ * @return GenericGuardToken
+ */
+ public function createAuthenticatedToken(UserInterface $user, $providerKey)
+ {
+ return new GenericGuardToken(
+ $user,
+ $providerKey,
+ $user->getRoles()
+ );
+ }
+} \ No newline at end of file