* Added user system with database features. This is fairly experimental and does not include dockerfile to automatically generate a mongodb. This should be in future commits along with ability to save hosts branching off this database feature. * Updated README, fixed a few bugs with user creation, and added docker support to run MongoDB (needs testing) * Changes to Dockerfile to fix error in installing MongoDB * Changes to Dockerfile to fix error in installing MongoDB * Changes to Dockerfile to fix error in installing MongoDB * Changes to Dockerfile to fix error in installing MongoDB * Changes to Dockerfile to fix error in installing MongoDB * Changes to Dockerfile to fix error in installing MongoDB * Changes to Dockerfile to fix error in installing MongoDB * Changes to Dockerfile to fix error in installing MongoDB * Changes to Dockerfile to fix error in installing MongoDB * Changes to Dockerfile to fix error in installing MongoDB * Changes to Dockerfile to fix error in installing MongoDB * Changes to Dockerfile to fix error in installing MongoDB * Changes to Dockerfile to fix error in installing MongoDB * Changes to Dockerfile to fix error in installing MongoDB * Changes to Dockerfile to fix error in installing MongoDB * Changes to Dockerfile to fix error in installing MongoDB * Changes to Dockerfile to fix error in installing MongoDB * Changes to Dockerfile to fix error in installing MongoDB * Changes to Dockerfile to fix error in installing MongoDB * Changes to Dockerfile to fix error in installing MongoDB * Changes to Dockerfile to fix error in connecting to sockets * Update README.md * Changes to connection system to support docker * Changes to connection system to support docker * Changes to connection system to support docker * Changes to connection system to support docker * Save hosts to tabs (very early version, not that many issues not just not very feature rich and has a poor UI that will be improved with more features) * Updated launchpad UI to be expandable in the future. Updated UI for the hosts to be able to easily configure them. They stil need organizational system (folders, etc.) * Better encryption for everything, new session login, rewrote a lot of database code changing its storage methods. Prepared for release of 2.0. * Updated database connection method. * Updated Profile modal to show username text more clearly * Updated Profile modal to show username text more clearly * Fixed control v pasting formating. Reorganized location of scripts. Visbile password and confirm password. Guest login. OpenSSH key authentication. Optional to remember password. Serach for host viewer. * Waits for user to be able to log in. Improved UI for profile, edit and add host, and added organizational features to the host app (Folders, search, etc.) * Updated various names for rsa keys to public keys, fixes ssh not connecting, better timing for editing host. * Added ability to share hosts. Fixed up overall UI errors in console and cleaned up code for release. * Fix GitHub build errors * Attempt #1 to auto compile MongoDB into the build to exclude it from the compose. * Attempt #2 to auto compile MongoDB into the build to exclude it from the compose. * Attempt #3 to auto compile MongoDB into the build to exclude it from the compose. * Attempt #3 to auto compile MongoDB into the build to exclude it from the compose.
166 lines
8.2 KiB
JavaScript
166 lines
8.2 KiB
JavaScript
import PropTypes from 'prop-types';
|
|
import { CssVarsProvider } from '@mui/joy/styles';
|
|
import { Modal, Button, FormControl, FormLabel, Input, Stack, DialogTitle, DialogContent, ModalDialog, IconButton } from '@mui/joy';
|
|
import theme from '/src/theme';
|
|
import { useEffect, useState } from 'react';
|
|
import Visibility from '@mui/icons-material/Visibility';
|
|
import VisibilityOff from '@mui/icons-material/VisibilityOff';
|
|
|
|
const CreateUserModal = ({ isHidden, form, setForm, handleCreateUser, setIsCreateUserHidden, setIsLoginUserHidden }) => {
|
|
const [confirmPassword, setConfirmPassword] = useState('');
|
|
const [showPassword, setShowPassword] = useState(false);
|
|
const [showConfirmPassword, setShowConfirmPassword] = useState(false);
|
|
|
|
const isFormValid = () => {
|
|
if (!form.username || !form.password || form.password !== confirmPassword) return false;
|
|
return true;
|
|
};
|
|
|
|
const handleCreate = () => {
|
|
handleCreateUser({
|
|
...form
|
|
});
|
|
};
|
|
|
|
useEffect(() => {
|
|
if (isHidden) {
|
|
setForm({ username: '', password: '' });
|
|
setConfirmPassword('');
|
|
}
|
|
}, [isHidden]);
|
|
|
|
return (
|
|
<CssVarsProvider theme={theme}>
|
|
<Modal open={!isHidden} onClose={() => {}}>
|
|
<ModalDialog
|
|
layout="center"
|
|
sx={{
|
|
backgroundColor: theme.palette.general.tertiary,
|
|
borderColor: theme.palette.general.secondary,
|
|
color: theme.palette.text.primary,
|
|
padding: 3,
|
|
borderRadius: 10,
|
|
width: "auto",
|
|
maxWidth: "90vw",
|
|
minWidth: "fit-content",
|
|
overflow: "hidden",
|
|
display: "flex",
|
|
flexDirection: "column",
|
|
alignItems: "center",
|
|
}}
|
|
>
|
|
<DialogTitle>Create</DialogTitle>
|
|
<DialogContent>
|
|
<form
|
|
onSubmit={(event) => {
|
|
event.preventDefault();
|
|
if (isFormValid()) handleCreate();
|
|
}}
|
|
>
|
|
<Stack spacing={2} sx={{ width: "100%", maxWidth: "100%", overflow: "hidden" }}>
|
|
<FormControl>
|
|
<FormLabel>Username</FormLabel>
|
|
<Input
|
|
value={form.username}
|
|
onChange={(event) => setForm({ ...form, username: event.target.value })}
|
|
sx={{
|
|
backgroundColor: theme.palette.general.primary,
|
|
color: theme.palette.text.primary,
|
|
}}
|
|
/>
|
|
</FormControl>
|
|
<FormControl>
|
|
<FormLabel>Password</FormLabel>
|
|
<div style={{ display: 'flex', alignItems: 'center' }}>
|
|
<Input
|
|
type={showPassword ? 'text' : 'password'}
|
|
value={form.password}
|
|
onChange={(event) => setForm({ ...form, password: event.target.value })}
|
|
sx={{
|
|
backgroundColor: theme.palette.general.primary,
|
|
color: theme.palette.text.primary,
|
|
flex: 1,
|
|
}}
|
|
/>
|
|
<IconButton
|
|
onClick={() => setShowPassword(!showPassword)}
|
|
sx={{
|
|
color: theme.palette.text.primary,
|
|
marginLeft: 1,
|
|
}}
|
|
>
|
|
{showPassword ? <VisibilityOff /> : <Visibility />}
|
|
</IconButton>
|
|
</div>
|
|
</FormControl>
|
|
<FormControl>
|
|
<FormLabel>Confirm Password</FormLabel>
|
|
<div style={{ display: 'flex', alignItems: 'center' }}>
|
|
<Input
|
|
type={showConfirmPassword ? 'text' : 'password'}
|
|
value={confirmPassword}
|
|
onChange={(event) => setConfirmPassword(event.target.value)}
|
|
sx={{
|
|
backgroundColor: theme.palette.general.primary,
|
|
color: theme.palette.text.primary,
|
|
flex: 1,
|
|
}}
|
|
/>
|
|
<IconButton
|
|
onClick={() => setShowConfirmPassword(!showConfirmPassword)}
|
|
sx={{
|
|
color: theme.palette.text.primary,
|
|
marginLeft: 1,
|
|
}}
|
|
>
|
|
{showConfirmPassword ? <VisibilityOff /> : <Visibility />}
|
|
</IconButton>
|
|
</div>
|
|
</FormControl>
|
|
<Button
|
|
type="submit"
|
|
disabled={!isFormValid()}
|
|
sx={{
|
|
backgroundColor: theme.palette.general.primary,
|
|
'&:hover': {
|
|
backgroundColor: theme.palette.general.disabled,
|
|
},
|
|
}}
|
|
>
|
|
Create
|
|
</Button>
|
|
<Button
|
|
onClick={() => {
|
|
setForm({ username: '', password: '' });
|
|
setConfirmPassword('');
|
|
setIsCreateUserHidden(true);
|
|
setIsLoginUserHidden(false);
|
|
}}
|
|
sx={{
|
|
backgroundColor: theme.palette.general.primary,
|
|
'&:hover': {
|
|
backgroundColor: theme.palette.general.disabled,
|
|
},
|
|
}}
|
|
>
|
|
Back
|
|
</Button>
|
|
</Stack>
|
|
</form>
|
|
</DialogContent>
|
|
</ModalDialog>
|
|
</Modal>
|
|
</CssVarsProvider>
|
|
);
|
|
};
|
|
|
|
CreateUserModal.propTypes = {
|
|
isHidden: PropTypes.bool.isRequired,
|
|
form: PropTypes.object.isRequired,
|
|
setForm: PropTypes.func.isRequired,
|
|
handleCreateUser: PropTypes.func.isRequired,
|
|
setIsCreateUserHidden: PropTypes.func.isRequired,
|
|
setIsLoginUserHidden: PropTypes.func.isRequired,
|
|
};
|
|
|
|
export default CreateUserModal; |