mirror of
https://github.com/Grasscutters/GrassClipper.git
synced 2024-11-16 04:45:34 +00:00
only show login when it is enabled on the server
This commit is contained in:
parent
7ef3d516fa
commit
6db54958d5
@ -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':
|
||||
|
@ -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')
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user