import React, { useEffect, useState } from 'react'; import { ServerContext } from '@/state/server'; import Modal from '@/components/elements/Modal'; import tw from 'twin.macro'; import Button from '@/components/elements/Button'; import FlashMessageRender from '@/components/FlashMessageRender'; import useFlash from '@/plugins/useFlash'; import { SocketEvent, SocketRequest } from '@/components/server/events'; import Field from '@/components/elements/Field'; import updateStartupVariable from '@/api/server/updateStartupVariable'; import { Form, Formik } from 'formik'; interface Values { gslToken: string; } const GSLTokenModalFeature = () => { const [ visible, setVisible ] = useState(false); const [ loading, setLoading ] = useState(false); const uuid = ServerContext.useStoreState(state => state.server.data!.uuid); const status = ServerContext.useStoreState(state => state.status.value); const { clearFlashes, clearAndAddHttpError } = useFlash(); const { connected, instance } = ServerContext.useStoreState(state => state.socket); useEffect(() => { if (!connected || !instance || status === 'running') return; const errors = [ '(gsl token expired)', '(account not found)', ]; const listener = (line: string) => { if (errors.some(p => line.toLowerCase().includes(p))) { setVisible(true); } }; instance.addListener(SocketEvent.CONSOLE_OUTPUT, listener); return () => { instance.removeListener(SocketEvent.CONSOLE_OUTPUT, listener); }; }, [ connected, instance, status ]); const updateGSLToken = (values: Values) => { setLoading(true); clearFlashes('feature:gslToken'); updateStartupVariable(uuid, 'STEAM_ACC', values.gslToken) .then(() => { if (instance) { instance.send(SocketRequest.SET_STATE, 'restart'); } setLoading(false); setVisible(false); }) .catch(error => { console.error(error); clearAndAddHttpError({ key: 'feature:gslToken', error }); }) .then(() => setLoading(false)); }; useEffect(() => { clearFlashes('feature:gslToken'); }, []); return ( setVisible(false)} closeOnBackground={false} showSpinnerOverlay={loading}>

Invalid GSL token!

It seems like your Gameserver Login Token (GSL token) is invalid or has expired.

You can either generate a new one and enter it below or leave the field blank to remove it completely.

); }; export default GSLTokenModalFeature;