Permalink
Browse files

[Security] Remove hard dependency on $providerKey for default auth su…

…ccess handler
  • Loading branch information...
1 parent d4b40fb commit 5e6c06fc708b10a20946dc4637af8235e042f214 @asm89 committed Jul 11, 2012
@@ -175,8 +175,8 @@ protected function createAuthenticationSuccessHandler($container, $id, $config)
$successHandlerId = 'security.authentication.success_handler.'.$id;
$successHandler = $container->setDefinition($successHandlerId, new DefinitionDecorator('security.authentication.success_handler'));
- $successHandler->replaceArgument(1, $id);
- $successHandler->replaceArgument(2, array_intersect_key($config, $this->defaultSuccessHandlerOptions));
+ $successHandler->replaceArgument(1, array_intersect_key($config, $this->defaultSuccessHandlerOptions));
+ $successHandler->addMethodCall('setProviderKey', array($id));
return $successHandlerId;
}
@@ -110,7 +110,6 @@
<service id="security.authentication.success_handler" class="%security.authentication.success_handler.class%" abstract="true" public="false">
<argument type="service" id="security.http_utils" />
- <argument />
<argument type="collection" /> <!-- Options -->
</service>
@@ -35,13 +35,11 @@ class DefaultAuthenticationSuccessHandler implements AuthenticationSuccessHandle
* Constructor.
*
* @param HttpUtils $httpUtils
- * @param string $providerKey
* @param array $options Options for processing a successful authentication attempt.
*/
- public function __construct(HttpUtils $httpUtils, $providerKey, array $options)
+ public function __construct(HttpUtils $httpUtils, array $options)
{
$this->httpUtils = $httpUtils;
- $this->providerKey = $providerKey;
$this->options = array_merge(array(
'always_use_default_target_path' => false,
@@ -60,6 +58,27 @@ public function onAuthenticationSuccess(Request $request, TokenInterface $token)
return $this->httpUtils->createRedirectResponse($request, $this->determineTargetUrl($request));
}
+
+ /**
+ * Get the provider key.
+ *
+ * @return string
+ */
+ public function getProviderKey()
+ {
+ return $this->providerKey;
+ }
+
+ /**
+ * Set the provider key.
+ *
+ * @param string $providerKey
+ */
+ public function setProviderKey($providerKey)
+ {
+ $this->providerKey = $providerKey;
+ }
+
/**
* Builds the target URL according to the defined options.
*
@@ -77,9 +96,8 @@ protected function determineTargetUrl(Request $request)
return $targetUrl;
}
- $session = $request->getSession();
- if ($targetUrl = $session->get('_security.'.$this->providerKey.'.target_path')) {
- $session->remove('_security.'.$this->providerKey.'.target_path');
+ if (null !== $this->providerKey && $targetUrl = $request->getSession()->get('_security.'.$this->providerKey.'.target_path')) {
+ $request->getSession()->remove('_security.'.$this->providerKey.'.target_path');
return $targetUrl;
}

0 comments on commit 5e6c06f

Please sign in to comment.