fix: add comma dangles
This commit is contained in:
parent
9e4152e298
commit
212c69d303
32 changed files with 152 additions and 137 deletions
|
@ -45,7 +45,7 @@
|
|||
"@types/multer": "^1.4.6",
|
||||
"@types/node": "^15.12.2",
|
||||
"babel-plugin-transform-imports": "^2.0.0",
|
||||
"eslint": "7.28.0",
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-config-next": "11.0.0",
|
||||
"husky": "^6.0.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import React from 'react';
|
||||
import {
|
||||
Backdrop as MuiBackdrop,
|
||||
CircularProgress
|
||||
CircularProgress,
|
||||
} from '@material-ui/core';
|
||||
|
||||
export default function Backdrop({ open }) {
|
||||
|
|
|
@ -2,7 +2,7 @@ import React from 'react';
|
|||
import {
|
||||
Card as MuiCard,
|
||||
CardContent,
|
||||
Typography
|
||||
Typography,
|
||||
} from '@material-ui/core';
|
||||
|
||||
export default function Card(props) {
|
||||
|
|
|
@ -8,7 +8,7 @@ import {
|
|||
Dialog,
|
||||
DialogTitle,
|
||||
DialogActions,
|
||||
DialogContent
|
||||
DialogContent,
|
||||
} from '@material-ui/core';
|
||||
import AudioIcon from '@material-ui/icons/Audiotrack';
|
||||
import copy from 'copy-to-clipboard';
|
||||
|
@ -16,7 +16,7 @@ import useFetch from 'hooks/useFetch';
|
|||
|
||||
export default function Image({ image, updateImages }) {
|
||||
const [open, setOpen] = useState(false);
|
||||
const [t,] = useState(image.mimetype.split('/')[0]);
|
||||
const [t] = useState(image.mimetype.split('/')[0]);
|
||||
|
||||
const handleDelete = async () => {
|
||||
const res = await useFetch('/api/user/files', 'DELETE', { id: image.id });
|
||||
|
@ -40,7 +40,7 @@ export default function Image({ image, updateImages }) {
|
|||
'video': <video controls {...props} />,
|
||||
// eslint-disable-next-line jsx-a11y/alt-text
|
||||
'image': <img {...props} />,
|
||||
'audio': <audio controls {...props} />
|
||||
'audio': <audio controls {...props} />,
|
||||
}[t];
|
||||
};
|
||||
|
||||
|
|
|
@ -48,18 +48,18 @@ const items = [
|
|||
{
|
||||
icon: <HomeIcon />,
|
||||
text: 'Home',
|
||||
link: '/dashboard'
|
||||
link: '/dashboard',
|
||||
},
|
||||
{
|
||||
icon: <FolderIcon />,
|
||||
text: 'Files',
|
||||
link: '/dashboard/files'
|
||||
link: '/dashboard/files',
|
||||
},
|
||||
{
|
||||
icon: <UploadIcon />,
|
||||
text: 'Upload',
|
||||
link: '/dashboard/upload'
|
||||
}
|
||||
link: '/dashboard/upload',
|
||||
},
|
||||
];
|
||||
|
||||
const drawerWidth = 240;
|
||||
|
@ -153,7 +153,7 @@ export default function Layout({ children, user, loading, noPaper }) {
|
|||
|
||||
const handleUpdateTheme = async (event: React.ChangeEvent<{ value: string }>) => {
|
||||
const newUser = await useFetch('/api/user', 'PATCH', {
|
||||
systemTheme: event.target.value || 'dark_blue'
|
||||
systemTheme: event.target.value || 'dark_blue',
|
||||
});
|
||||
|
||||
setSystemTheme(newUser.systemTheme);
|
||||
|
@ -168,7 +168,7 @@ export default function Layout({ children, user, loading, noPaper }) {
|
|||
<ResetTokenDialog open={resetOpen} setOpen={setResetOpen} setToken={setToken} />
|
||||
<Toolbar
|
||||
sx={{
|
||||
width: { xs: drawerWidth }
|
||||
width: { xs: drawerWidth },
|
||||
}}
|
||||
>
|
||||
<AppBar
|
||||
|
@ -177,7 +177,7 @@ export default function Layout({ children, user, loading, noPaper }) {
|
|||
sx={{
|
||||
borderBottom: 1,
|
||||
borderBottomColor: t => t.palette.divider,
|
||||
display: { xs: 'none', sm: 'block' }
|
||||
display: { xs: 'none', sm: 'block' },
|
||||
}}
|
||||
>
|
||||
<Toolbar>
|
||||
|
@ -293,7 +293,7 @@ export default function Layout({ children, user, loading, noPaper }) {
|
|||
elevation={0}
|
||||
sx={{
|
||||
width: { sm: `calc(100% - ${drawerWidth}px)` },
|
||||
ml: { sm: `${drawerWidth}px` }
|
||||
ml: { sm: `${drawerWidth}px` },
|
||||
}}
|
||||
>
|
||||
<Toolbar>
|
||||
|
@ -363,7 +363,7 @@ export default function Layout({ children, user, loading, noPaper }) {
|
|||
component='nav'
|
||||
sx={{
|
||||
width: { sm: drawerWidth },
|
||||
flexShrink: { sm: 0 }
|
||||
flexShrink: { sm: 0 },
|
||||
}}
|
||||
>
|
||||
<Drawer
|
||||
|
@ -373,11 +373,11 @@ export default function Layout({ children, user, loading, noPaper }) {
|
|||
open={mobileOpen}
|
||||
elevation={0}
|
||||
ModalProps={{
|
||||
keepMounted: true
|
||||
keepMounted: true,
|
||||
}}
|
||||
sx={{
|
||||
display: { xs: 'block', sm: 'none' },
|
||||
'* .MuiDrawer-paper': { boxSizing: 'border-box', width: drawerWidth }
|
||||
'* .MuiDrawer-paper': { boxSizing: 'border-box', width: drawerWidth },
|
||||
}}
|
||||
>
|
||||
{drawer}
|
||||
|
@ -386,7 +386,7 @@ export default function Layout({ children, user, loading, noPaper }) {
|
|||
variant='permanent'
|
||||
sx={{
|
||||
display: { xs: 'none', sm: 'block' },
|
||||
'* .MuiDrawer-paper': { boxSizing: 'border-box', width: drawerWidth }
|
||||
'* .MuiDrawer-paper': { boxSizing: 'border-box', width: drawerWidth },
|
||||
}}
|
||||
open
|
||||
>
|
||||
|
|
|
@ -23,7 +23,7 @@ export const themes = {
|
|||
'ayu_light': ayu_light,
|
||||
'nord': nord,
|
||||
'polar': polar,
|
||||
'dracula': dracula
|
||||
'dracula': dracula,
|
||||
};
|
||||
|
||||
export const friendlyThemeName = {
|
||||
|
@ -34,7 +34,7 @@ export const friendlyThemeName = {
|
|||
'ayu_light': 'Ayu Light',
|
||||
'nord': 'Nord',
|
||||
'polar': 'Polar',
|
||||
'dracula': 'Dracula'
|
||||
'dracula': 'Dracula',
|
||||
};
|
||||
|
||||
export default function ZiplineTheming({ Component, pageProps }) {
|
||||
|
@ -54,8 +54,8 @@ export default function ZiplineTheming({ Component, pageProps }) {
|
|||
border: user.customTheme.border,
|
||||
background: {
|
||||
main: user.customTheme.mainBackground,
|
||||
paper: user.customTheme.paperBackground
|
||||
}
|
||||
paper: user.customTheme.paperBackground,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
t = themes[user.systemTheme] ?? themes.dark_blue;
|
||||
|
|
|
@ -14,7 +14,7 @@ import {
|
|||
Skeleton,
|
||||
CardActionArea,
|
||||
CardMedia,
|
||||
Card as MuiCard
|
||||
Card as MuiCard,
|
||||
} from '@material-ui/core';
|
||||
import AudioIcon from '@material-ui/icons/Audiotrack';
|
||||
|
||||
|
@ -48,7 +48,7 @@ const columns = [
|
|||
minWidth: 170,
|
||||
align: 'right' as Aligns,
|
||||
format: (value) => new Date(value).toLocaleString(),
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
function StatText({ children }) {
|
||||
|
@ -229,7 +229,7 @@ export default function Dashboard() {
|
|||
<StatTable
|
||||
columns={[
|
||||
{ id: 'username', name: 'Name' },
|
||||
{ id: 'count', name: 'Images' }
|
||||
{ id: 'count', name: 'Images' },
|
||||
]}
|
||||
rows={stats ? stats.count_by_user : []} />
|
||||
</Card>
|
||||
|
@ -237,7 +237,7 @@ export default function Dashboard() {
|
|||
<StatTable
|
||||
columns={[
|
||||
{ id: 'mimetype', name: 'Type' },
|
||||
{ id: 'count', name: 'Count' }
|
||||
{ id: 'count', name: 'Count' },
|
||||
]}
|
||||
rows={stats ? stats.types_count : []} />
|
||||
</Card>
|
||||
|
|
|
@ -14,7 +14,7 @@ import { useRouter } from 'next/router';
|
|||
const validationSchema = yup.object({
|
||||
username: yup
|
||||
.string()
|
||||
.required('Username is required')
|
||||
.required('Username is required'),
|
||||
});
|
||||
|
||||
const themeValidationSchema = yup.object({
|
||||
|
@ -94,11 +94,11 @@ export default function Manage() {
|
|||
Headers: {
|
||||
Authorization: user?.token,
|
||||
...(withEmbed && {Embed: 'true'}),
|
||||
...(withZws && {ZWS: 'true'})
|
||||
...(withZws && {ZWS: 'true'}),
|
||||
},
|
||||
URL: '$json:url$',
|
||||
Body: 'MultipartFormData',
|
||||
FileFormName: 'file'
|
||||
FileFormName: 'file',
|
||||
};
|
||||
|
||||
const pseudoElement = document.createElement('a');
|
||||
|
@ -115,7 +115,7 @@ export default function Manage() {
|
|||
username: user.username,
|
||||
password: '',
|
||||
embedTitle: user.embedTitle ?? '',
|
||||
embedColor: user.embedColor
|
||||
embedColor: user.embedColor,
|
||||
},
|
||||
validationSchema,
|
||||
onSubmit: async values => {
|
||||
|
@ -132,7 +132,7 @@ export default function Manage() {
|
|||
username: cleanUsername,
|
||||
password: cleanPassword === '' ? null : cleanPassword,
|
||||
embedTitle: cleanEmbedTitle === '' ? null : cleanEmbedTitle,
|
||||
embedColor: cleanEmbedColor === '' ? null : cleanEmbedColor
|
||||
embedColor: cleanEmbedColor === '' ? null : cleanEmbedColor,
|
||||
};
|
||||
|
||||
const newUser = await useFetch('/api/user', 'PATCH', data);
|
||||
|
@ -149,7 +149,7 @@ export default function Manage() {
|
|||
setSeverity('success');
|
||||
setOpen(true);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const customThemeFormik = useFormik({
|
||||
|
@ -182,7 +182,7 @@ export default function Manage() {
|
|||
setSeverity('success');
|
||||
setOpen(true);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
|
|
|
@ -28,9 +28,9 @@ export default function Upload({ route }) {
|
|||
const res = await fetch('/api/upload', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Authorization': user.token
|
||||
'Authorization': user.token,
|
||||
},
|
||||
body
|
||||
body,
|
||||
});
|
||||
const json = await res.json();
|
||||
if (res.ok && json.error === undefined) {
|
||||
|
@ -65,7 +65,7 @@ export default function Upload({ route }) {
|
|||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
display: 'block',
|
||||
p: 5
|
||||
p: 5,
|
||||
}}
|
||||
{...getRootProps()}
|
||||
>
|
||||
|
|
|
@ -13,7 +13,7 @@ import {
|
|||
Button,
|
||||
TextField,
|
||||
Switch,
|
||||
FormControlLabel
|
||||
FormControlLabel,
|
||||
} from '@material-ui/core';
|
||||
import { Delete as DeleteIcon, Add as AddIcon } from '@material-ui/icons';
|
||||
|
||||
|
@ -59,7 +59,7 @@ function CreateUserDialog({ open, setOpen, updateUsers, setSeverity, setMessage,
|
|||
initialValues: {
|
||||
username: '',
|
||||
password: '',
|
||||
administrator: false
|
||||
administrator: false,
|
||||
},
|
||||
onSubmit: async (values) => {
|
||||
const cleanUsername = values.username.trim();
|
||||
|
@ -70,7 +70,7 @@ function CreateUserDialog({ open, setOpen, updateUsers, setSeverity, setMessage,
|
|||
const data = {
|
||||
username: cleanUsername,
|
||||
password: cleanPassword,
|
||||
administrator: values.administrator
|
||||
administrator: values.administrator,
|
||||
};
|
||||
|
||||
setOpen(false);
|
||||
|
@ -87,7 +87,7 @@ function CreateUserDialog({ open, setOpen, updateUsers, setSeverity, setMessage,
|
|||
updateUsers();
|
||||
}
|
||||
setLoading(false);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
|
@ -96,7 +96,7 @@ function CreateUserDialog({ open, setOpen, updateUsers, setSeverity, setMessage,
|
|||
open={open}
|
||||
onClose={() => setOpen(false)}
|
||||
PaperProps={{
|
||||
elevation: 1
|
||||
elevation: 1,
|
||||
}}
|
||||
>
|
||||
<DialogTitle>
|
||||
|
@ -151,7 +151,7 @@ export default function Users() {
|
|||
|
||||
const handleDelete = async (user) => {
|
||||
const res = await useFetch('/api/users', 'DELETE', {
|
||||
id: user.id
|
||||
id: user.id,
|
||||
});
|
||||
if (res.error) {
|
||||
setMessage(`Could not delete ${user.username}`);
|
||||
|
|
|
@ -5,7 +5,7 @@ export default async function useFetch(url: string, method: 'GET' | 'POST' | 'PA
|
|||
const res = await global.fetch(url, {
|
||||
body: body ? JSON.stringify(body) : null,
|
||||
method,
|
||||
headers
|
||||
headers,
|
||||
});
|
||||
|
||||
return res.json();
|
||||
|
|
|
@ -45,7 +45,7 @@ export const withZipline = (handler: (req: NextApiRequest, res: NextApiResponse)
|
|||
res.error = (message: string) => {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.json({
|
||||
error: message
|
||||
error: message,
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -53,7 +53,7 @@ export const withZipline = (handler: (req: NextApiRequest, res: NextApiResponse)
|
|||
res.setHeader('Content-Type', 'application/json');
|
||||
res.status(403);
|
||||
res.json({
|
||||
error: '403: ' + message
|
||||
error: '403: ' + message,
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -61,7 +61,7 @@ export const withZipline = (handler: (req: NextApiRequest, res: NextApiResponse)
|
|||
res.setHeader('Content-Type', 'application/json');
|
||||
res.status(401);
|
||||
res.json({
|
||||
error: '403: ' + message
|
||||
error: '403: ' + message,
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -82,7 +82,7 @@ export const withZipline = (handler: (req: NextApiRequest, res: NextApiResponse)
|
|||
res.setHeader('Set-Cookie', serialize(name, '', {
|
||||
path: '/',
|
||||
expires: new Date(1),
|
||||
maxAge: undefined
|
||||
maxAge: undefined,
|
||||
}));
|
||||
};
|
||||
req.user = async () => {
|
||||
|
@ -92,7 +92,7 @@ export const withZipline = (handler: (req: NextApiRequest, res: NextApiResponse)
|
|||
|
||||
const user = await prisma.user.findFirst({
|
||||
where: {
|
||||
id: Number(userId)
|
||||
id: Number(userId),
|
||||
},
|
||||
select: {
|
||||
administrator: true,
|
||||
|
@ -103,8 +103,8 @@ export const withZipline = (handler: (req: NextApiRequest, res: NextApiResponse)
|
|||
systemTheme: true,
|
||||
customTheme: true,
|
||||
token: true,
|
||||
username: true
|
||||
}
|
||||
username: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (!user) return null;
|
||||
|
|
|
@ -12,6 +12,6 @@ export default createTheme({
|
|||
border: '#191e29',
|
||||
background: {
|
||||
main: '#0A0E14',
|
||||
paper: '#0D1016'
|
||||
}
|
||||
paper: '#0D1016',
|
||||
},
|
||||
});
|
|
@ -12,6 +12,6 @@ export default createTheme({
|
|||
border: '#e3e3e3',
|
||||
background: {
|
||||
main: '#FAFAFA',
|
||||
paper: '#FFFFFF'
|
||||
}
|
||||
paper: '#FFFFFF',
|
||||
},
|
||||
});
|
|
@ -12,6 +12,6 @@ export default createTheme({
|
|||
border: '#363c4d',
|
||||
background: {
|
||||
main: '#1F2430',
|
||||
paper: '#232834'
|
||||
}
|
||||
paper: '#232834',
|
||||
},
|
||||
});
|
|
@ -10,6 +10,6 @@ export default createTheme({
|
|||
border: '#2b2b2b',
|
||||
background: {
|
||||
main: '#000000',
|
||||
paper: '#060606'
|
||||
}
|
||||
paper: '#060606',
|
||||
},
|
||||
});
|
|
@ -10,6 +10,6 @@ export default createTheme({
|
|||
border: '#1b2541',
|
||||
background: {
|
||||
main: '#05070f',
|
||||
paper: '#0c101c'
|
||||
}
|
||||
paper: '#0c101c',
|
||||
},
|
||||
});
|
|
@ -12,6 +12,6 @@ export default createTheme({
|
|||
border: '#7D8096',
|
||||
background: {
|
||||
main: '#282A36',
|
||||
paper: '#44475A'
|
||||
}
|
||||
paper: '#44475A',
|
||||
},
|
||||
});
|
||||
|
|
|
@ -45,9 +45,9 @@ export default function createTheme(o: ThemeOptions) {
|
|||
MuiTableHead: {
|
||||
styleOverrides: {
|
||||
root: {
|
||||
backgroundColor: o.border
|
||||
}
|
||||
}
|
||||
backgroundColor: o.border,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -12,6 +12,6 @@ export default createTheme({
|
|||
border: '#565e70',
|
||||
background: {
|
||||
main: '#2E3440',
|
||||
paper: '#3B4252'
|
||||
}
|
||||
paper: '#3B4252',
|
||||
},
|
||||
});
|
|
@ -12,6 +12,6 @@ export default createTheme({
|
|||
border: '#989fab',
|
||||
background: {
|
||||
main: '#D8DEE9',
|
||||
paper: '#E5E9F0'
|
||||
}
|
||||
paper: '#E5E9F0',
|
||||
},
|
||||
});
|
|
@ -17,8 +17,8 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
|||
|
||||
const existing = await prisma.user.findFirst({
|
||||
where: {
|
||||
username
|
||||
}
|
||||
username,
|
||||
},
|
||||
});
|
||||
if (existing) return res.forbid('user exists');
|
||||
|
||||
|
@ -29,8 +29,8 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
|||
password: hashed,
|
||||
username,
|
||||
token: createToken(),
|
||||
administrator
|
||||
}
|
||||
administrator,
|
||||
},
|
||||
});
|
||||
|
||||
delete newUser.password;
|
||||
|
|
|
@ -15,16 +15,16 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
|||
username: 'administrator',
|
||||
password: await hashPassword('password'),
|
||||
token: createToken(),
|
||||
administrator: true
|
||||
}
|
||||
administrator: true,
|
||||
},
|
||||
});
|
||||
Logger.get('database').info('created default user:\nUsername: "administrator"\nPassword: "password"');
|
||||
}
|
||||
|
||||
const user = await prisma.user.findFirst({
|
||||
where: {
|
||||
username
|
||||
}
|
||||
username,
|
||||
},
|
||||
});
|
||||
|
||||
if (!user) return res.status(404).end(JSON.stringify({ error: 'User not found' }));
|
||||
|
|
|
@ -12,8 +12,8 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
|||
const byUser = await prisma.image.groupBy({
|
||||
by: ['userId'],
|
||||
_count: {
|
||||
_all: true
|
||||
}
|
||||
_all: true,
|
||||
},
|
||||
});
|
||||
const count_users = await prisma.user.count();
|
||||
|
||||
|
@ -21,13 +21,13 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
|||
for (let i = 0, L = byUser.length; i !== L; ++i) {
|
||||
const user = await prisma.user.findFirst({
|
||||
where: {
|
||||
id: byUser[i].userId
|
||||
}
|
||||
id: byUser[i].userId,
|
||||
},
|
||||
});
|
||||
|
||||
count_by_user.push({
|
||||
username: user.username,
|
||||
count: byUser[i]._count._all
|
||||
count: byUser[i]._count._all,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -35,14 +35,14 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
|||
const viewsCount = await prisma.image.groupBy({
|
||||
by: ['views'],
|
||||
_sum: {
|
||||
views: true
|
||||
}
|
||||
views: true,
|
||||
},
|
||||
});
|
||||
|
||||
const typesCount = await prisma.image.groupBy({
|
||||
by: ['mimetype'],
|
||||
_count: {
|
||||
mimetype: true
|
||||
mimetype: true,
|
||||
},
|
||||
});
|
||||
const types_count = [];
|
||||
|
@ -55,7 +55,7 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
|||
count_by_user: count_by_user.sort((a,b) => b.count-a.count),
|
||||
count_users,
|
||||
views_count: (viewsCount[0]?._sum?.views ?? 0),
|
||||
types_count: types_count.sort((a,b) => b.count-a.count)
|
||||
types_count: types_count.sort((a,b) => b.count-a.count),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
|||
|
||||
const user = await prisma.user.findFirst({
|
||||
where: {
|
||||
token: req.headers.authorization
|
||||
}
|
||||
token: req.headers.authorization,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
|
@ -42,8 +42,8 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
|||
file: `${rand}.${ext}`,
|
||||
mimetype: file.mimetype,
|
||||
userId: user.id,
|
||||
embed: !!req.headers.embed
|
||||
}
|
||||
embed: !!req.headers.embed,
|
||||
},
|
||||
});
|
||||
|
||||
if (req.headers.zws) invis = await createInvisImage(zconfig.uploader.length, image.id);
|
||||
|
|
|
@ -15,8 +15,8 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
|||
|
||||
const image = await prisma.image.delete({
|
||||
where: {
|
||||
id: req.body.id
|
||||
}
|
||||
id: req.body.id,
|
||||
},
|
||||
});
|
||||
|
||||
await rm(join(process.cwd(), config.uploader.directory, image.file));
|
||||
|
@ -32,8 +32,8 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
|||
if (req.body.favorite !== null) image = await prisma.image.update({
|
||||
where: { id: req.body.id },
|
||||
data: {
|
||||
favorite: req.body.favorite
|
||||
}
|
||||
favorite: req.body.favorite,
|
||||
},
|
||||
});
|
||||
|
||||
return res.json(image);
|
||||
|
@ -41,15 +41,15 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
|||
let images = await prisma.image.findMany({
|
||||
where: {
|
||||
userId: user.id,
|
||||
favorite: !!req.query.favorite
|
||||
favorite: !!req.query.favorite,
|
||||
},
|
||||
select: {
|
||||
created_at: true,
|
||||
file: true,
|
||||
mimetype: true,
|
||||
id: true,
|
||||
favorite: true
|
||||
}
|
||||
favorite: true,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -12,38 +12,38 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
|||
const hashed = await hashPassword(req.body.password);
|
||||
await prisma.user.update({
|
||||
where: { id: user.id },
|
||||
data: { password: hashed }
|
||||
data: { password: hashed },
|
||||
});
|
||||
}
|
||||
|
||||
if (req.body.username) {
|
||||
const existing = await prisma.user.findFirst({
|
||||
where: {
|
||||
username: req.body.username
|
||||
}
|
||||
username: req.body.username,
|
||||
},
|
||||
});
|
||||
if (existing && user.username !== req.body.username) {
|
||||
return res.forbid('Username is already taken');
|
||||
}
|
||||
await prisma.user.update({
|
||||
where: { id: user.id },
|
||||
data: { username: req.body.username }
|
||||
data: { username: req.body.username },
|
||||
});
|
||||
}
|
||||
|
||||
if (req.body.embedTitle) await prisma.user.update({
|
||||
where: { id: user.id },
|
||||
data: { embedTitle: req.body.embedTitle }
|
||||
data: { embedTitle: req.body.embedTitle },
|
||||
});
|
||||
|
||||
if (req.body.embedColor) await prisma.user.update({
|
||||
where: { id: user.id },
|
||||
data: { embedColor: req.body.embedColor }
|
||||
data: { embedColor: req.body.embedColor },
|
||||
});
|
||||
|
||||
if (req.body.systemTheme) await prisma.user.update({
|
||||
where: { id: user.id },
|
||||
data: { systemTheme: req.body.systemTheme }
|
||||
data: { systemTheme: req.body.systemTheme },
|
||||
});
|
||||
|
||||
if (req.body.customTheme) {
|
||||
|
@ -52,21 +52,21 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
|||
data: {
|
||||
customTheme: {
|
||||
update: {
|
||||
...req.body.customTheme
|
||||
}
|
||||
}
|
||||
}
|
||||
...req.body.customTheme,
|
||||
},
|
||||
},
|
||||
},
|
||||
}); else await prisma.theme.create({
|
||||
data: {
|
||||
userId: user.id,
|
||||
...req.body.customTheme
|
||||
}
|
||||
...req.body.customTheme,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const newUser = await prisma.user.findFirst({
|
||||
where: {
|
||||
id: Number(user.id)
|
||||
id: Number(user.id),
|
||||
},
|
||||
select: {
|
||||
administrator: true,
|
||||
|
@ -78,8 +78,8 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
|||
systemTheme: true,
|
||||
customTheme: true,
|
||||
token: true,
|
||||
username: true
|
||||
}
|
||||
username: true,
|
||||
},
|
||||
});
|
||||
|
||||
Logger.get('user').info(`User ${user.username} (${newUser.username}) (${newUser.id}) was updated`);
|
||||
|
|
|
@ -15,13 +15,13 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
|||
userId: user.id,
|
||||
},
|
||||
orderBy: {
|
||||
created_at: 'desc'
|
||||
created_at: 'desc',
|
||||
},
|
||||
select: {
|
||||
created_at: true,
|
||||
file: true,
|
||||
mimetype: true
|
||||
}
|
||||
mimetype: true,
|
||||
},
|
||||
});
|
||||
|
||||
// @ts-ignore
|
||||
|
|
|
@ -10,11 +10,11 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
|||
if (req.method === 'PATCH') {
|
||||
const updated = await prisma.user.update({
|
||||
where: {
|
||||
id: user.id
|
||||
id: user.id,
|
||||
},
|
||||
data: {
|
||||
token: createToken()
|
||||
}
|
||||
token: createToken(),
|
||||
},
|
||||
});
|
||||
|
||||
Logger.get('user').info(`User ${user.username} (${user.id}) reset their token`);
|
||||
|
|
|
@ -14,15 +14,15 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
|||
|
||||
const deleteUser = await prisma.user.findFirst({
|
||||
where: {
|
||||
id: req.body.id
|
||||
}
|
||||
id: req.body.id,
|
||||
},
|
||||
});
|
||||
if (!deleteUser) return res.forbid('user doesn\'t exist');
|
||||
|
||||
await prisma.user.delete({
|
||||
where: {
|
||||
id: deleteUser.id
|
||||
}
|
||||
id: deleteUser.id,
|
||||
},
|
||||
});
|
||||
|
||||
delete deleteUser.password;
|
||||
|
@ -37,8 +37,8 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
|||
embedColor: true,
|
||||
embedTitle: true,
|
||||
customTheme: true,
|
||||
systemTheme: true
|
||||
}
|
||||
systemTheme: true,
|
||||
},
|
||||
});
|
||||
return res.json(users);
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ export default function Login() {
|
|||
const formik = useFormik({
|
||||
initialValues: {
|
||||
username: '',
|
||||
password: ''
|
||||
password: '',
|
||||
},
|
||||
onSubmit: async values => {
|
||||
const username = values.username.trim();
|
||||
|
@ -47,7 +47,7 @@ export default function Login() {
|
|||
|
||||
setLoadingOpen(true);
|
||||
const res = await useFetch('/api/auth/login', 'POST', {
|
||||
username, password
|
||||
username, password,
|
||||
});
|
||||
|
||||
if (res.error) {
|
||||
|
@ -61,7 +61,7 @@ export default function Login() {
|
|||
setMessage('Logged in');
|
||||
router.push('/dashboard');
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
|
|
33
yarn.lock
33
yarn.lock
|
@ -323,10 +323,10 @@
|
|||
resolved "https://registry.yarnpkg.com/@emotion/weak-memoize/-/weak-memoize-0.2.5.tgz#8eed982e2ee6f7f4e44c253e12962980791efd46"
|
||||
integrity sha512-6U71C2Wp7r5XtFtQzYrW5iKFT67OixrSxjI4MptCHzdSVlgabczzqLe0ZSgnub/5Kp4hSbpDB1tMytZY9pwxxA==
|
||||
|
||||
"@eslint/eslintrc@^0.4.2":
|
||||
version "0.4.2"
|
||||
resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.4.2.tgz#f63d0ef06f5c0c57d76c4ab5f63d3835c51b0179"
|
||||
integrity sha512-8nmGq/4ycLpIwzvhI4tNDmQztZ8sp+hI7cyG8i1nQDhkAbRzHpXPidRAHlNvCZQpJTKw5ItIpMw9RSToGF00mg==
|
||||
"@eslint/eslintrc@^0.4.3":
|
||||
version "0.4.3"
|
||||
resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.4.3.tgz#9e42981ef035beb3dd49add17acb96e8ff6f394c"
|
||||
integrity sha512-J6KFFz5QCYUJq3pf0mjEcCJVERbzv71PUIDczuh9JkwGEzced6CO5ADLHB1rbf/+oPBtoPfMYNOpGDzCANlbXw==
|
||||
dependencies:
|
||||
ajv "^6.12.4"
|
||||
debug "^4.1.1"
|
||||
|
@ -358,6 +358,20 @@
|
|||
resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-9.2.0.tgz#f3933a44e365864f4dad5db94158106d511e8131"
|
||||
integrity sha512-sqKVVVOe5ivCaXDWivIJYVSaEgdQK9ul7a4Kity5Iw7u9+wBAPbX1RMSnLLmp7O4Vzj0WOWwMAJsTL00xwaNug==
|
||||
|
||||
"@humanwhocodes/config-array@^0.5.0":
|
||||
version "0.5.0"
|
||||
resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.5.0.tgz#1407967d4c6eecd7388f83acf1eaf4d0c6e58ef9"
|
||||
integrity sha512-FagtKFz74XrTl7y6HCzQpwDfXP0yhxe9lHLD1UZxjvZIcbyRz8zTFF/yYNfSfzU414eDwZ1SrO0Qvtyf+wFMQg==
|
||||
dependencies:
|
||||
"@humanwhocodes/object-schema" "^1.2.0"
|
||||
debug "^4.1.1"
|
||||
minimatch "^3.0.4"
|
||||
|
||||
"@humanwhocodes/object-schema@^1.2.0":
|
||||
version "1.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.0.tgz#87de7af9c231826fdd68ac7258f77c429e0e5fcf"
|
||||
integrity sha512-wdppn25U8z/2yiaT6YGquE6X8sSv7hNMWSXYSSU1jGv/yd6XqjXgTDJ8KP4NgjTXfJ3GbRjeeb8RTV7a/VpM+w==
|
||||
|
||||
"@iarna/toml@2.2.5":
|
||||
version "2.2.5"
|
||||
resolved "https://registry.yarnpkg.com/@iarna/toml/-/toml-2.2.5.tgz#b32366c89b43c6f8cefbdefac778b9c828e3ba8c"
|
||||
|
@ -2245,13 +2259,14 @@ eslint-visitor-keys@^2.0.0:
|
|||
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz#f65328259305927392c938ed44eb0a5c9b2bd303"
|
||||
integrity sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==
|
||||
|
||||
eslint@7.28.0:
|
||||
version "7.28.0"
|
||||
resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.28.0.tgz#435aa17a0b82c13bb2be9d51408b617e49c1e820"
|
||||
integrity sha512-UMfH0VSjP0G4p3EWirscJEQ/cHqnT/iuH6oNZOB94nBjWbMnhGEPxsZm1eyIW0C/9jLI0Fow4W5DXLjEI7mn1g==
|
||||
eslint@^7.32.0:
|
||||
version "7.32.0"
|
||||
resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.32.0.tgz#c6d328a14be3fb08c8d1d21e12c02fdb7a2a812d"
|
||||
integrity sha512-VHZ8gX+EDfz+97jGcgyGCyRia/dPOd6Xh9yPv8Bl1+SoaIwD+a/vlrOmGRUyOYu7MwUhc7CxqeaDZU13S4+EpA==
|
||||
dependencies:
|
||||
"@babel/code-frame" "7.12.11"
|
||||
"@eslint/eslintrc" "^0.4.2"
|
||||
"@eslint/eslintrc" "^0.4.3"
|
||||
"@humanwhocodes/config-array" "^0.5.0"
|
||||
ajv "^6.10.0"
|
||||
chalk "^4.0.0"
|
||||
cross-spawn "^7.0.2"
|
||||
|
|
Loading…
Reference in a new issue