small adjustments and bugfixes

This commit is contained in:
Jan Naahs 2020-06-26 11:58:54 +02:00
parent 774c40bfa5
commit d6f7487bc8
4 changed files with 12 additions and 10 deletions

View File

@ -28,6 +28,7 @@ const App = () => {
const handleAuthenticationStatus = async () => {
const status = await user.status();
setIsAuthenticated(status.success);
await updateServerStatus();
};
const handleLogout = async () => {

View File

@ -77,9 +77,9 @@ const Layout = ({children, handleLogout, serverStatus, updateServerStatus}) => {
</div>
</div>
<div className="py-4 px-2 accentuated">
<h1 className="text-dirty-white text-lg mb-2 mx-4">Administration</h1>
<h1 className="text-dirty-white text-lg mb-2 mx-4">FSM Administration</h1>
<div className="text-white text-center rounded-sm bg-black shadow-inner mx-4 p-1">
<Link to="/user-management">User Management</Link>
<Link to="/user-management">Users</Link>
<Link to="/help" last={true}>Help</Link>
</div>
</div>

View File

@ -11,21 +11,22 @@ const Login = ({handleLogin}) => {
const location = useLocation()
const onSubmit = async data => {
const status = await user.login(data)
if (status.success) {
handleLogin()
history.push('/')
const loginAttempt = await user.login(data)
if (loginAttempt.success) {
await handleLogin();
history.push('/');
}
};
// on mount check if user is authenticated
useEffect(() => {
user.status().then(status => {
(async () => {
const status = await user.status()
if (status.success) {
handleLogin()
await handleLogin();
history.push(location?.state?.from || '/');
}
})
})();
}, [])
return (

View File

@ -10,7 +10,7 @@ export default {
return response.data;
},
stop: async () => {
const response = await client.post('/api/server/stop');
const response = await client.get('/api/server/stop');
return response.data;
},
start: async (ip, port, savefile) => {