mirror of
https://github.com/Grasscutters/GrassClipper.git
synced 2024-08-14 13:11:48 +08: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');
|
elm.style.removeProperty('display');
|
||||||
|
|
||||||
|
// Remove classification classes
|
||||||
|
elm.classList.remove('error');
|
||||||
|
elm.classList.remove('success');
|
||||||
|
elm.classList.remove('warn');
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case 'error':
|
case 'error':
|
||||||
elm.classList.add('error');
|
elm.classList.add('error');
|
||||||
@ -34,6 +39,11 @@ async function displayRegisterAlert(message, type, cooldown = null) {
|
|||||||
const text = document.getElementById('registerAlertText');
|
const text = document.getElementById('registerAlertText');
|
||||||
|
|
||||||
elm.style.removeProperty('display');
|
elm.style.removeProperty('display');
|
||||||
|
|
||||||
|
// Remove classification classes
|
||||||
|
elm.classList.remove('error');
|
||||||
|
elm.classList.remove('success');
|
||||||
|
elm.classList.remove('warn');
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case 'error':
|
case 'error':
|
||||||
|
@ -286,12 +286,25 @@ async function closeSettings() {
|
|||||||
|
|
||||||
async function openLogin() {
|
async function openLogin() {
|
||||||
const login = document.querySelector('#loginPanel')
|
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 loginIpDisplay = document.querySelector('#loginPopupServer')
|
||||||
const registerIpDisplay = document.querySelector('#registerPopupServer')
|
const registerIpDisplay = document.querySelector('#registerPopupServer')
|
||||||
|
|
||||||
|
const config = await getCfg()
|
||||||
|
const useHttps = config.useHttps
|
||||||
|
const url = `${useHttps ? 'https' : 'http'}://${ip}:${port}`;
|
||||||
|
|
||||||
loginIpDisplay.innerText = ip.value
|
// Check if we even need to authenticate
|
||||||
registerIpDisplay.innerText = ip.value
|
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') {
|
if (login.style.display === 'none') {
|
||||||
login.style.removeProperty('display')
|
login.style.removeProperty('display')
|
||||||
|
@ -90,6 +90,7 @@ async function login() {
|
|||||||
await Neutralino.clipboard.writeText(tkData.token)
|
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);
|
displayLoginAlert('Login successful! Token copied to clipboard. Paste this token into the username field of the game to log in.', 'success', 8000);
|
||||||
|
launchPrivate()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user