wsj-filenaming/logout.php
2026-03-02 21:49:38 +00:00

69 lines
2.5 KiB
PHP

<?php
require_once __DIR__ . '/config.php';
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
// Destroy PHP session
$_SESSION = [];
if (ini_get('session.use_cookies')) {
$params = session_get_cookie_params();
setcookie(session_name(), '', time() - 42000,
$params['path'], $params['domain'],
$params['secure'], $params['httponly']
);
}
session_destroy();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Signing Out…</title>
<link rel="stylesheet" href="style.css">
<style>
body { display:flex; align-items:center; justify-content:center; min-height:100vh; margin:0; }
.auth-card { text-align:center; padding:48px 40px; background:var(--card-bg); border:1px solid var(--border-color); border-radius:8px; max-width:400px; width:90%; }
.spinner-ring { display:inline-block; width:40px; height:40px; border:3px solid var(--border-color); border-top-color:var(--text-primary); border-radius:50%; animation:spin .8s linear infinite; margin-bottom:20px; }
@keyframes spin { to { transform:rotate(360deg); } }
</style>
</head>
<body>
<div class="auth-card">
<div class="spinner-ring"></div>
<p style="color:var(--text-secondary)">Signing out&hellip;</p>
</div>
<script src="https://alcdn.msauth.net/browser/2.32.2/js/msal-browser.min.js"></script>
<script>
(function () {
const msalConfig = {
auth: {
clientId: '<?php echo AZURE_CLIENT_ID; ?>',
authority: 'https://login.microsoftonline.com/<?php echo AZURE_TENANT_ID; ?>',
redirectUri: '<?php echo AZURE_REDIRECT_URI; ?>'
},
cache: { cacheLocation: 'sessionStorage', storeAuthStateInCookie: false }
};
const msalInstance = new msal.PublicClientApplication(msalConfig);
msalInstance.handleRedirectPromise().then(() => {
const accounts = msalInstance.getAllAccounts();
if (accounts.length > 0) {
msalInstance.logoutRedirect({
account: accounts[0],
postLogoutRedirectUri: '<?php echo AZURE_REDIRECT_URI; ?>'
});
} else {
// No MSAL account — just go back to app root (triggers re-login)
window.location.href = 'index.php';
}
}).catch(() => {
window.location.href = 'index.php';
});
})();
</script>
</body>
</html>