forked from spacebar/SplatNet
Add log out support
This commit is contained in:
parent
82794e6f22
commit
ba0814eecd
9 changed files with 132 additions and 56 deletions
|
|
@ -4,6 +4,17 @@ fetch("../header.html")
|
|||
const headerContainer = document.getElementById("header-container");
|
||||
headerContainer.innerHTML = html;
|
||||
|
||||
const logoutForm = document.getElementById("logout-form");
|
||||
if (logoutForm && typeof CONFIG !== 'undefined') {
|
||||
const apiBase = CONFIG.API_BASE_URL.replace(/\/$/, "");
|
||||
logoutForm.action = apiBase + "/api/v1/spfn/logout";
|
||||
|
||||
const originInput = document.getElementById("logout_frontend_origin");
|
||||
if (originInput) {
|
||||
originInput.value = window.location.origin;
|
||||
}
|
||||
}
|
||||
|
||||
const friendButton = headerContainer.querySelector('.menu-item.equipment');
|
||||
if (friendButton) {
|
||||
friendButton.classList.add('active');
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
<link rel="icon" href="../favicon.ico" type="image/x-icon" />
|
||||
<link rel="stylesheet" href="styles.css" />\
|
||||
<script src="/assets/general.js"></script>
|
||||
<script src="/config.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="header-container"></div>
|
||||
|
|
|
|||
|
|
@ -4,6 +4,17 @@ fetch("../header.html")
|
|||
const headerContainer = document.getElementById("header-container");
|
||||
headerContainer.innerHTML = html;
|
||||
|
||||
const logoutForm = document.getElementById("logout-form");
|
||||
if (logoutForm && typeof CONFIG !== 'undefined') {
|
||||
const apiBase = CONFIG.API_BASE_URL.replace(/\/$/, "");
|
||||
logoutForm.action = apiBase + "/api/v1/spfn/logout";
|
||||
|
||||
const originInput = document.getElementById("logout_frontend_origin");
|
||||
if (originInput) {
|
||||
originInput.value = window.location.origin;
|
||||
}
|
||||
}
|
||||
|
||||
const friendButton = headerContainer.querySelector('.menu-item.friend');
|
||||
if (friendButton) {
|
||||
friendButton.classList.add('active');
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
<link rel="icon" href="../favicon.ico" type="image/x-icon" />
|
||||
<link rel="stylesheet" href="styles.css" />
|
||||
<script src="/assets/general.js"></script>
|
||||
<script src="/config.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="header-container"></div>
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="stylesheet" href="../style.css" />
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
|
@ -62,12 +63,17 @@
|
|||
<img src="../assets/en/svg/text/menu/tx_twitter-47ce083cc4514ab6aeb75b7dd9f71ce89ddc54a18d930d90cf4df62047413831.svg" class="btn-label-img" alt="Unlink Twitter">
|
||||
</button>
|
||||
|
||||
<button class="box-btn">
|
||||
<form id="logout-form" method="POST" style="display: contents;" accept-charset="UTF-8">
|
||||
<input type="hidden" name="frontend_origin" id="logout_frontend_origin">
|
||||
<button type="submit" class="box-btn">
|
||||
<img src="../assets/en/svg/text/menu/tx_logout-a35c74ff79b585667ae273fd9477f07a9d07c7fce8f5ef24f8f8f43988b5afcb.svg" class="btn-label-img" alt="Log Out">
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<script src="config.js"></script>
|
||||
<script src="logout.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
21
logout.js
Normal file
21
logout.js
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
$(document).ready(function () {
|
||||
const form = $("#logout-form");
|
||||
if (typeof CONFIG === 'undefined') {
|
||||
alert("CRITICAL ERROR: config.js not loaded before logout.js");
|
||||
return;
|
||||
}
|
||||
|
||||
const apiBase = CONFIG.API_BASE_URL;
|
||||
const targetAction = apiBase.replace(/\/$/, "") + "/spfn/logout";
|
||||
$("#logout_frontend_origin").val(window.location.origin);
|
||||
form.attr("action", targetAction);
|
||||
|
||||
console.log("Form action set to: " + targetAction);
|
||||
|
||||
form.submit(function(e) {
|
||||
alert("Submitting to: " + $(this).attr("action"));
|
||||
|
||||
const submitBtn = $(":submit", this);
|
||||
submitBtn.prop("disabled", true).css("opacity", "0.5");
|
||||
});
|
||||
});
|
||||
|
|
@ -6,6 +6,7 @@
|
|||
<link rel="icon" href="../favicon.ico" type="image/x-icon" />
|
||||
<link rel="stylesheet" href="styles.css" />
|
||||
<script src="/assets/general.js"></script>
|
||||
<script src="/config.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="header-container"></div>
|
||||
|
|
|
|||
|
|
@ -4,6 +4,17 @@ fetch("../header.html")
|
|||
const headerContainer = document.getElementById("header-container");
|
||||
headerContainer.innerHTML = html;
|
||||
|
||||
const logoutForm = document.getElementById("logout-form");
|
||||
if (logoutForm && typeof CONFIG !== 'undefined') {
|
||||
const apiBase = CONFIG.API_BASE_URL.replace(/\/$/, "");
|
||||
logoutForm.action = apiBase + "/api/v1/spfn/logout";
|
||||
|
||||
const originInput = document.getElementById("logout_frontend_origin");
|
||||
if (originInput) {
|
||||
originInput.value = window.location.origin;
|
||||
}
|
||||
}
|
||||
|
||||
const friendButton = headerContainer.querySelector('.menu-item.rank');
|
||||
if (friendButton) {
|
||||
friendButton.classList.add('active');
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
<link rel="icon" href="../favicon.ico" type="image/x-icon" />
|
||||
<link rel="stylesheet" href="styles.css" />
|
||||
<script src="/assets/general.js"></script>
|
||||
<script src="/config.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
|
@ -46,6 +47,18 @@
|
|||
.then(res => res.text())
|
||||
.then(html => {
|
||||
headerBox.innerHTML = html;
|
||||
|
||||
const logoutForm = document.getElementById("logout-form");
|
||||
if (logoutForm && typeof CONFIG !== 'undefined') {
|
||||
const apiBase = CONFIG.API_BASE_URL.replace(/\/$/, "");
|
||||
logoutForm.action = apiBase + "/api/v1/spfn/logout";
|
||||
|
||||
const originInput = document.getElementById("logout_frontend_origin");
|
||||
if (originInput) {
|
||||
originInput.value = window.location.origin;
|
||||
}
|
||||
}
|
||||
|
||||
const friendButton = headerBox.querySelector('.menu-item.stage');
|
||||
if (friendButton) {
|
||||
friendButton.classList.add('active');
|
||||
|
|
|
|||
Loading…
Reference in a new issue