only show login when it is enabled on the server

This commit is contained in:
SpikeHD 2022-04-26 22:53:55 -07:00
parent 7ef3d516fa
commit 6db54958d5
3 changed files with 27 additions and 3 deletions

View File

@ -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':

View File

@ -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')

View File

@ -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;
}
}