diff --git a/resources/js/authAlert.js b/resources/js/authAlert.js index 476f21f..fa2bed0 100644 --- a/resources/js/authAlert.js +++ b/resources/js/authAlert.js @@ -6,6 +6,11 @@ async function displayLoginAlert(message, type, cooldown = null) { elm.style.removeProperty('display'); + // Remove classification classes + elm.classList.remove('error'); + elm.classList.remove('success'); + elm.classList.remove('warn'); + switch(type) { case 'error': elm.classList.add('error'); @@ -34,6 +39,11 @@ async function displayRegisterAlert(message, type, cooldown = null) { const text = document.getElementById('registerAlertText'); elm.style.removeProperty('display'); + + // Remove classification classes + elm.classList.remove('error'); + elm.classList.remove('success'); + elm.classList.remove('warn'); switch(type) { case 'error': diff --git a/resources/js/index.js b/resources/js/index.js index 0dee14e..fdece6c 100644 --- a/resources/js/index.js +++ b/resources/js/index.js @@ -286,12 +286,25 @@ async function closeSettings() { async function openLogin() { const login = document.querySelector('#loginPanel') - const ip = document.querySelector('#ip') + const ip = document.querySelector('#ip').value + const port = document.querySelector('#port').value const loginIpDisplay = document.querySelector('#loginPopupServer') const registerIpDisplay = document.querySelector('#registerPopupServer') + + const config = await getCfg() + const useHttps = config.useHttps + const url = `${useHttps ? 'https' : 'http'}://${ip}:${port}`; - loginIpDisplay.innerText = ip.value - registerIpDisplay.innerText = ip.value + // Check if we even need to authenticate + const { data } = await axios.get(url + '/grasscutter/auth_status') + + if (data.message !== 'AUTH_ENABLED') { + launchPrivate() + return + } + + loginIpDisplay.innerText = ip + registerIpDisplay.innerText = ip if (login.style.display === 'none') { login.style.removeProperty('display') diff --git a/resources/js/login.js b/resources/js/login.js index 388acba..085c3af 100644 --- a/resources/js/login.js +++ b/resources/js/login.js @@ -90,6 +90,7 @@ async function login() { await Neutralino.clipboard.writeText(tkData.token) displayLoginAlert('Login successful! Token copied to clipboard. Paste this token into the username field of the game to log in.', 'success', 8000); + launchPrivate() break; } }