SplatNet/users/auth/splatfestival/splatfestivalyay.js

43 lines
1.3 KiB
JavaScript
Raw Normal View History

2026-02-06 23:01:30 +01:00
$(document).ready(function () {
const form = $("#auth-form");
const errorContainer = $("#auth-error");
2026-02-05 10:40:13 +01:00
const urlParams = new URLSearchParams(window.location.search);
2026-02-06 23:01:30 +01:00
const apiBase = CONFIG.API_BASE_URL;
2026-02-05 10:40:13 +01:00
2026-02-06 23:01:30 +01:00
$("#frontend_origin").val(window.location.origin);
form.attr("action", apiBase + "/api/v2/sso/spfn/generate_token");
async function checkExistingSession() {
try {
const response = await fetch(apiBase + "/api/v1/users/me", {
method: 'GET',
credentials: 'include'
});
if (response.ok) {
window.location.href = "/friend_list/";
}
} catch (err) {
console.log("auth check failed");
2026-02-05 10:40:13 +01:00
}
2026-02-06 23:01:30 +01:00
}
if (!urlParams.has('error')) {
checkExistingSession();
}
if (urlParams.has('error')) {
errorContainer.text("Invalid SFID or Password").show();
if (urlParams.has('username')) {
$("input[name='username']").val(urlParams.get('username'));
2026-02-05 10:40:13 +01:00
}
}
2026-02-06 23:01:30 +01:00
form.submit(function() {
const submitBtn = $(":submit", this);
submitBtn.prop("disabled", true).val("Signing In...");
setTimeout(function() {
submitBtn.prop("disabled", false).val("Sign In");
}, 10000);
});
});