Skip to content

Commit fc0e7dd

Browse files
Merge pull request #184 from a-menshchikov/firewall_name_1.x
Use target_path according the current firewall (instead of hardcoded "main")
2 parents 7245edd + 923fd16 commit fc0e7dd

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

Controller/SamlController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,21 @@ public function loginAction(Request $request)
1313
{
1414
$session = $request->getSession();
1515
$authErrorKey = Security::AUTHENTICATION_ERROR;
16+
$error = null;
1617

1718
if ($request->attributes->has($authErrorKey)) {
1819
$error = $request->attributes->get($authErrorKey);
1920
} elseif (null !== $session && $session->has($authErrorKey)) {
2021
$error = $session->get($authErrorKey);
2122
$session->remove($authErrorKey);
22-
} else {
23-
$error = null;
2423
}
2524

26-
if ($error) {
25+
if ($error instanceof \Exception) {
2726
throw new \RuntimeException($error->getMessage());
2827
}
2928

30-
$this->get('onelogin_auth')->login($session->get('_security.main.target_path'));
29+
$firewallName = array_slice(explode('.', trim($request->attributes->get('_firewall_context'))), -1)[0];
30+
$this->get('onelogin_auth')->login($session->get('_security.'.$firewallName.'.target_path'));
3131
}
3232

3333
public function metadataAction()

0 commit comments

Comments
 (0)