Skip to content

Commit 197c4e8

Browse files
committed
cleanup
1 parent b02ce61 commit 197c4e8

5 files changed

Lines changed: 19 additions & 44 deletions

File tree

src/Glpi/Controller/Security/ReAuthController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public function verify(Request $request): Response
8989
if ($this->reAuthManager->verify((string) $user_input)) {
9090
$this->reAuthManager->authenticate();
9191

92+
// catched in RedirectPostExceptionListener
9293
throw new ReauthRedirectException(
9394
$this->reAuthManager->getRedirectURL(),
9495
$this->reAuthManager->getRedirectData(),

src/Glpi/Kernel/Listener/ExceptionListener/RedirectPostExceptionListener.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,12 @@ public function onKernelException(ExceptionEvent $event): void
6161
return;
6262
}
6363

64-
// The original CSRF token was already consumed during the initial request validation.
65-
// Remove it so the Twig template can inject a fresh one via {{ csrf_token() }}.
66-
$post_data = $throwable->getData();
67-
unset($post_data['_glpi_csrf_token']);
68-
6964
// Carry the original URL as a POST field so that Html::getRefererUrl() can return
7065
// the correct "back" URL on the replayed request.
7166
// Without this, the browser would send Referer: /ReAuth/Verify (the page that served
7267
// this auto-submit form), causing Html::back() to redirect to the wrong place.
73-
$post_data['_glpi_http_referer'] = $throwable->getUrl();
68+
$post_data = $throwable->getData();
69+
$post_data['_glpi_http_referer'] = $throwable->getUrl(); // @todo sert encore ?
7470
7571
$response = new Response(
7672
TemplateRenderer::getInstance()->render('pages/redirect_post.html.twig', [

src/Html.php

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2073,30 +2073,8 @@ public static function showMassiveActions($options = [])
20732073
);
20742074
}
20752075
}
2076-
}
2077-
else
2078-
{
2079-
// @todo revert
2080-
// Reauth is needed : "Actions" button will trigger redirection to ReAuth/Prompt page instead of opening massive action modal
2081-
// if($p['reauth_needed'] === true) {
2082-
// $out = '<a role="button" class="'. htmlescape($p['action_button_classes']) . '" href="/ReAuth/Prompt" >Reauth</a>';
2083-
// // normalement : passer par reauthManager::redirect()
2084-
// // @todo i18n
2085-
// // @todo laisser le même libélé pour ne pas perturber les utilisateurs
2086-
// // @todo manque le ~glpi_rootdoc
2087-
// // path: "/ReAuth/Prompt",
2088-
// // name: "reauth_prompt",
2089-
// if ($p['display']) {
2090-
// echo $out;
2091-
// return true; // @todo false ??
2092-
// } else {
2093-
// return $out;
2094-
// }
2095-
// }
2096-
2076+
} else {
20972077
// Create Modal window on top
2098-
2099-
21002078
if (
21012079
$p['ontop']
21022080
|| (isset($p['forcecreate']) && $p['forcecreate'])

src/MassiveAction.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,7 @@ public static function getAllMassiveActions($item, $is_deleted = false, ?CommonD
614614
return false;
615615
}
616616

617+
/** @var CommonDBTM $item */
617618
if (!is_null($checkitem)) {
618619
$canupdate = $checkitem->canUpdate();
619620
$candelete = $checkitem->canDelete();
@@ -820,7 +821,7 @@ public function showSubForm()
820821
**/
821822
public function showDefaultSubForm()
822823
{
823-
echo Html::submit(_x('button', 'Post 3'), [
824+
echo Html::submit(_x('button', 'Post 3'), [ // @todo cleanup
824825
'name' => 'massiveaction',
825826
'icon' => 'ti ti-device-floppy',
826827
'class' => 'btn btn-sm btn-primary',
@@ -852,8 +853,7 @@ public static function showMassiveActionsSubForm(MassiveAction $ma)
852853
'multiple' => true,
853854
]);
854855
echo '<br>';
855-
echo Html::submit(_x('button', 'Post'), [
856-
echo Html::submit(_x('button', 'Post 4'), [
856+
echo Html::submit(_x('button', 'Post 4'), [ // @todo cleanup
857857
'name' => 'massiveaction',
858858
]);
859859
return true;
@@ -1174,7 +1174,7 @@ public static function showMassiveActionsSubForm(MassiveAction $ma)
11741174
if (isset($ma->POST['submitname']) && $ma->POST['submitname']) {
11751175
$submitname = $ma->POST['submitname'];
11761176
} else {
1177-
$submitname = _x('button', 'Post 5');
1177+
$submitname = _x('button', 'Post 5'); // @todo cleanup
11781178
$submit_options['icon'] = 'ti ti-device-floppy';
11791179
}
11801180
echo Html::submit($submitname, $submit_options);
@@ -1206,7 +1206,7 @@ public static function showMassiveActionsSubForm(MassiveAction $ma)
12061206
if (isset($ma->POST['submitname']) && $ma->POST['submitname']) {
12071207
$submitname = $ma->POST['submitname'];
12081208
} else {
1209-
$submitname = _x('button', 'Post 6');
1209+
$submitname = _x('button', 'Post 6'); // @todo cleanup
12101210
$submit_options['icon'] = 'ti ti-device-floppy';
12111211
}
12121212
echo Html::submit($submitname, $submit_options);
@@ -1232,7 +1232,7 @@ public static function showMassiveActionsSubForm(MassiveAction $ma)
12321232
if (isset($ma->POST['submitname']) && $ma->POST['submitname']) {
12331233
$submitname = $ma->POST['submitname'];
12341234
} else {
1235-
$submitname = _x('button', 'Post 7');
1235+
$submitname = _x('button', 'Post 7'); // @todo cleanup
12361236
$submit_options['icon'] = 'ti ti-device-floppy';
12371237
}
12381238
echo Html::submit($submitname, $submit_options);

src/Session.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,15 @@ public static function init(Auth $auth)
181181

182182
self::loadLanguage();
183183

184-
if ($auth->password_expired) {
185-
// Make sure we are not in debug mode, as it could trigger some ajax request that would
186-
// fail the session check (as we use a special partial session here without profiles) and thus
187-
// destroy the session.
188-
$_SESSION["glpi_use_mode"] = self::NORMAL_MODE;
189-
$_SESSION['glpi_password_expired'] = 1;
190-
// Do not init profiles, as user has to update its password to be able to use GLPI
191-
return;
192-
}
184+
if ($auth->password_expired) {
185+
// Make sure we are not in debug mode, as it could trigger some ajax request that would
186+
// fail the session check (as we use a special partial session here without profiles) and thus
187+
// destroy the session.
188+
$_SESSION["glpi_use_mode"] = self::NORMAL_MODE;
189+
$_SESSION['glpi_password_expired'] = 1;
190+
// Do not init profiles, as user has to update its password to be able to use GLPI
191+
return;
192+
}
193193

194194
// glpiprofiles -> other available profile with link to the associated entities
195195
Plugin::doHook(Hooks::INIT_SESSION);

0 commit comments

Comments
 (0)