diff --git a/compte.php b/compte.php index b87cf88..6aa2951 100644 --- a/compte.php +++ b/compte.php @@ -107,7 +107,8 @@ if ($strCode != 'compte_login' && $strCode != 'compte_motdepasse' && $strCode != } // Déjà connecté sur login / mot de passe / inscription : accueil compte, sans polluer redirect_after_login. -if (($strCode == 'compte_login' || $strCode == 'compte_motdepasse' || $strCode == 'compte_nouveau' || $strCode == 'compte_reset') && isset($_SESSION['com_id'])) { +// MSIN-4401 — compte_reset exclu : géré dans fxShowFormReset (conflit autre session). +if (($strCode == 'compte_login' || $strCode == 'compte_motdepasse' || $strCode == 'compte_nouveau') && isset($_SESSION['com_id'])) { header('Location: ' . $vDomaine . '/' . $strPage); exit; } diff --git a/php/inc_fx_compte.php b/php/inc_fx_compte.php index e974b8b..609c4e0 100644 --- a/php/inc_fx_compte.php +++ b/php/inc_fx_compte.php @@ -1351,6 +1351,19 @@ function fxLogout($strLangue = 'fr') exit; } + // MSIN-4401 — retour vers lien reset après déconnexion (chemin relatif sûr uniquement). + if (!empty($_GET['return'])) { + $strReturn = (string)$_GET['return']; + if ($strReturn !== '' && $strReturn[0] === '/' + && preg_match('#^/(compte|account)/reset(\?|$)#i', $strReturn) + && strpos($strReturn, '//') === false + && strpos($strReturn, "\n") === false + && strpos($strReturn, "\r") === false) { + header('Location: ' . $vDomaine . $strReturn); + exit; + } + } + header('Location: ' . $vDomaine . '/' . $strPage); exit; } @@ -1364,6 +1377,59 @@ function fxShowFormReset($arrData, $strLangue) $infoCompte = $objDatabase->fxGetRow($sqlCourriel); if ($infoCompte != null) { + // MSIN-4401 — déjà connecté sous un autre compte : ne pas afficher le formulaire. + $intSessionComId = intval($_SESSION['com_id'] ?? 0); + $intTargetComId = intval($infoCompte['com_id']); + if ($intSessionComId > 0 && $intSessionComId !== $intTargetComId) { + $strSessionLabel = trim( + (string)($_SESSION['com_info']['com_prenom'] ?? $_SESSION['com_prenom'] ?? '') + . ' ' + . (string)($_SESSION['com_info']['com_nom'] ?? '') + ); + if ($strSessionLabel === '') { + $strSessionLabel = (string)($_SESSION['com_info']['com_courriel'] ?? ('#' . $intSessionComId)); + } + $strTargetLabel = trim(($infoCompte['com_prenom'] ?? '') . ' ' . ($infoCompte['com_nom'] ?? '')); + if ($strTargetLabel === '') { + $strTargetLabel = (string)$infoCompte['com_courriel']; + } + $strReturnPath = ($strLangue === 'en' ? '/account' : '/compte') . '/reset?' + . http_build_query(array( + 't' => $arrData['t'], + 'm' => $arrData['m'], + 'id' => $arrData['id'], + )); + $strLogoutUrl = $vDomaine . '/logout.php?lang=' . urlencode($strLangue) + . '&return=' . rawurlencode($strReturnPath); + $strStayUrl = $vDomaine . '/' . ($strLangue === 'en' ? 'account' : 'compte'); + ?> + + + fxEscape($arrData['com_password_a']), PASSWORD_DEFAULT); $sqlUpdate = "UPDATE inscriptions_comptes SET com_password = '" . $strPassword . "', com_reset_token = ''