summaryrefslogtreecommitdiffstats
path: root/Core/Exception
diff options
context:
space:
mode:
authorRyan Weaver <ryan@thatsquality.com>2015-09-20 20:41:52 -0400
committerRyan Weaver <ryan@thatsquality.com>2015-09-20 20:44:39 -0400
commit7e00d82e77d150ac8c328e65248845eaa2d95442 (patch)
tree0cf40d5a71b497bf7f06b3aa53accf834ec3ebf3 /Core/Exception
parent1aa1d1b25ee51760e703df10ca383cd3a6e957e4 (diff)
downloadsymfony-security-7e00d82e77d150ac8c328e65248845eaa2d95442.zip
symfony-security-7e00d82e77d150ac8c328e65248845eaa2d95442.tar.gz
symfony-security-7e00d82e77d150ac8c328e65248845eaa2d95442.tar.bz2
Adding a new exception and throwing it when the User changes
This is quite technical. As you can see in the provider, the method is called sometimes when the User changes, and so the token becomes de-authenticated (e.g. someone else changes the password between requests). In practice, the user should be unauthenticated. Using the anonymous token did this, but throwing an AccountStatusException seems like a better idea. It needs to be an AccountStatusException because the ExceptionListener from the Firewall looks for exceptions of this class and logs the user out when they are found (because this is their purpose).
Diffstat (limited to 'Core/Exception')
-rw-r--r--Core/Exception/AuthenticationExpiredException.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/Core/Exception/AuthenticationExpiredException.php b/Core/Exception/AuthenticationExpiredException.php
new file mode 100644
index 0000000..caf2e6c
--- /dev/null
+++ b/Core/Exception/AuthenticationExpiredException.php
@@ -0,0 +1,31 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Security\Core\Exception;
+
+/**
+ * AuthenticationServiceException is thrown when an authenticated token becomes un-authentcated between requests.
+ *
+ * In practice, this is due to the User changing between requests (e.g. password changes),
+ * causes the token to become un-authenticated.
+ *
+ * @author Ryan Weaver <ryan@knpuniversity.com>
+ */
+class AuthenticationExpiredException extends AccountStatusException
+{
+ /**
+ * {@inheritdoc}
+ */
+ public function getMessageKey()
+ {
+ return 'Authentication expired because your account information has changed.';
+ }
+}