mirror of
https://github.com/itflow-org/itflow
synced 2026-12-01 08:39:01 +00:00
QoL 45: intval and floatval in place of int and float casts and a string cast in place of strval, redirect in place of raw Location headers wherever functions.php is loaded, redirect fallback escapes the URL with json_encode and escapeHtml, escapeHtml for the last htmlspecialchars on a page, and the plain-HTTP cookie notice through flashAlert
This commit is contained in:
@@ -23,8 +23,7 @@ $settings = mysqli_fetch_assoc($sql_settings);
|
||||
|
||||
// No portal, no portal sign-in - as with a password
|
||||
if (intval($settings['config_client_portal_enable'] ?? 0) !== 1) {
|
||||
header("Location: ../login.php");
|
||||
exit();
|
||||
redirect("../login.php");
|
||||
}
|
||||
|
||||
$client_id = $settings['config_azure_client_id'];
|
||||
@@ -61,8 +60,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET" && !isset($_GET['code']) && !isset($_GET
|
||||
'scope' => 'https://graph.microsoft.com/User.Read',
|
||||
'state' => $state);
|
||||
|
||||
header('Location: '.$auth_code_url.'?'.http_build_query($params));
|
||||
exit();
|
||||
redirect($auth_code_url . '?' . http_build_query($params));
|
||||
|
||||
}
|
||||
|
||||
@@ -79,14 +77,12 @@ if (isset($_GET['code']) || isset($_GET['error'])) {
|
||||
|
||||
if (!empty($_GET['error'])) {
|
||||
$_SESSION['login_message'] = 'Something went wrong with logging you in: Microsoft returned an error. Please try again.';
|
||||
header("Location: ../login.php");
|
||||
exit();
|
||||
redirect("../login.php");
|
||||
}
|
||||
|
||||
if (empty($state) || empty($session_state) || !hash_equals($session_state, $state) || time() > $session_state_expires) {
|
||||
$_SESSION['login_message'] = 'Something went wrong with logging you in: the sign-in request could not be verified. Please try again.';
|
||||
header("Location: ../login.php");
|
||||
exit();
|
||||
redirect("../login.php");
|
||||
}
|
||||
|
||||
$params = array (
|
||||
@@ -132,8 +128,7 @@ if (isset($_GET['code']) || isset($_GET['error'])) {
|
||||
// Something went wrong verifying the token/using the Graph API - quit
|
||||
error_log("ITFlow: MS Graph API error during client portal Entra login: " . json_encode($msgraph_response['error']));
|
||||
$_SESSION['login_message'] = 'Something went wrong with logging you in: could not read your profile from Microsoft. Please try again.';
|
||||
header("Location: ../login.php");
|
||||
exit();
|
||||
redirect("../login.php");
|
||||
|
||||
} elseif (isset($msgraph_response['id'])) {
|
||||
|
||||
@@ -177,7 +172,7 @@ if (isset($_GET['code']) || isset($_GET['error'])) {
|
||||
// Logging
|
||||
logAudit("Client Login", "Success", "Client contact $upn successfully logged in via Entra", $client_id, $user_id);
|
||||
|
||||
header("Location: index.php");
|
||||
redirect("index.php");
|
||||
|
||||
} else {
|
||||
|
||||
@@ -187,27 +182,22 @@ if (isset($_GET['code']) || isset($_GET['error'])) {
|
||||
|
||||
$_SESSION['login_message'] = 'Something went wrong with logging you in: Your account is not configured for Entra SSO. Please ensure you are setup in ITFlow as a contact and have Entra SSO configured.';
|
||||
|
||||
header("Location: ../login.php");
|
||||
redirect("../login.php");
|
||||
}
|
||||
|
||||
exit();
|
||||
|
||||
}
|
||||
|
||||
header('Location: index.php');
|
||||
exit();
|
||||
redirect('index.php');
|
||||
|
||||
} else {
|
||||
|
||||
error_log("ITFlow: no access_token returned during client portal Entra login");
|
||||
$_SESSION['login_message'] = 'Something went wrong with logging you in: Microsoft did not return an access token. Please try again.';
|
||||
header("Location: ../login.php");
|
||||
exit();
|
||||
redirect("../login.php");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// If the user is just sat on the page, send them back to log in to try again
|
||||
header("Location: ../login.php");
|
||||
exit();
|
||||
redirect("../login.php");
|
||||
|
||||
Reference in New Issue
Block a user