Skip to content
This repository was archived by the owner on Sep 19, 2022. It is now read-only.

Commit 45a9a2d

Browse files
melangervyskocilpavel
authored andcommitted
Limit copy-paste in DatabaseCommand.php
1 parent b658c5b commit 45a9a2d

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

lib/Auth/Process/DatabaseCommand.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,26 @@ public static function insertLogin(&$request, &$date)
1919
$statisticsTableName = $databaseConnector->getStatisticsTableName();
2020
$identityProvidersMapTableName = $databaseConnector->getIdentityProvidersMapTableName();
2121
$serviceProvidersMapTableName = $databaseConnector->getServiceProvidersMapTableName();
22+
23+
if (!in_array($databaseConnector->getMode(), ['PROXY', 'IDP', 'SP'])) {
24+
throw new Exception('Unknown mode is set. Mode has to be one of the following: PROXY, IDP, SP.');
25+
}
26+
27+
if ($databaseConnector->getMode() !== 'IDP') {
28+
$idpName = $request['Attributes']['sourceIdPName'][0];
29+
$idpEntityID = $request['saml:sp:IdP'];
30+
}
31+
if ($databaseConnector->getMode() !== 'SP') {
32+
$spEntityId = $request['Destination']['entityid'];
33+
$spName = $request['Destination']['name']['en'];
34+
}
2235

2336
if ($databaseConnector->getMode() === 'IDP') {
2437
$idpName = $databaseConnector->getIdpName();
2538
$idpEntityID = $databaseConnector->getIdpEntityId();
26-
$spEntityId = $request['Destination']['entityid'];
27-
$spName = $request['Destination']['name']['en'];
2839
} elseif ($databaseConnector->getMode() === 'SP') {
29-
$idpName = $request['Attributes']['sourceIdPName'][0];
30-
$idpEntityID = $request['saml:sp:IdP'];
3140
$spEntityId = $databaseConnector->getSpEntityId();
3241
$spName = $databaseConnector->getSpName();
33-
} elseif ($databaseConnector->getMode() === 'PROXY') {
34-
$idpName = $request['Attributes']['sourceIdPName'][0];
35-
$idpEntityID = $request['saml:sp:IdP'];
36-
$spEntityId = $request['Destination']['entityid'];
37-
$spName = $request['Destination']['name']['en'];
38-
} else {
39-
throw new Exception('Unknown mode is set. Mode has to be one of the following: PROXY, IDP, SP.');
4042
}
4143

4244
$year = $date->format('Y');

0 commit comments

Comments
 (0)