mirror of https://github.com/AlphaNecron/Void.git
chore(api): use `authorization` instead of `token` for auth header
This commit is contained in:
parent
307fb89723
commit
818e35bc9e
|
@ -19,7 +19,6 @@ module.exports = {
|
||||||
'react/react-in-jsx-scope': 'error',
|
'react/react-in-jsx-scope': 'error',
|
||||||
'react/require-render-return': 'error',
|
'react/require-render-return': 'error',
|
||||||
'react/style-prop-object': 'warn',
|
'react/style-prop-object': 'warn',
|
||||||
'@next/next/no-img-element': 'off',
|
'@next/next/no-img-element': 'off'
|
||||||
'react/no-find-dom-node': 'off'
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
yarn install # or npm install
|
yarn install # or npm install
|
||||||
cp config.example.toml config.toml
|
cp config.example.toml config.toml
|
||||||
nano config.toml # edit the config file
|
nano config.toml # edit the config file
|
||||||
yarn build # or npm build
|
yarn build # or npm run build
|
||||||
yarn start # or npm start
|
yarn start # or npm start
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@
|
||||||
- Discord bot
|
- Discord bot
|
||||||
|
|
||||||
### Contribution
|
### Contribution
|
||||||
- All contribution must be made in `dev` branch, other contributions in `v0` will be rejected.
|
- All contribution must be made in `dev` branch, contributions in `v0` will be closed.
|
||||||
|
|
||||||
### Todo
|
### Todo
|
||||||
- Docker support
|
- Docker support
|
||||||
|
|
|
@ -16,7 +16,7 @@ export default function ShareXDialog({ open, onClose, token }) {
|
||||||
RequestMethod: 'POST',
|
RequestMethod: 'POST',
|
||||||
RequestURL: `${apiUrl}/upload`,
|
RequestURL: `${apiUrl}/upload`,
|
||||||
Headers: {
|
Headers: {
|
||||||
Token: token,
|
Authorization: token,
|
||||||
Generator: generator,
|
Generator: generator,
|
||||||
PreserveFileName: preserveFileName ? 'true' : ''
|
PreserveFileName: preserveFileName ? 'true' : ''
|
||||||
},
|
},
|
||||||
|
@ -34,7 +34,7 @@ export default function ShareXDialog({ open, onClose, token }) {
|
||||||
RequestMethod: 'POST',
|
RequestMethod: 'POST',
|
||||||
RequestURL: `${apiUrl}/shorten`,
|
RequestURL: `${apiUrl}/shorten`,
|
||||||
Headers: {
|
Headers: {
|
||||||
Token: token
|
Authorization: token
|
||||||
},
|
},
|
||||||
Body: 'FormURLEncoded',
|
Body: 'FormURLEncoded',
|
||||||
Arguments: {
|
Arguments: {
|
||||||
|
|
|
@ -29,7 +29,7 @@ export default function Upload() {
|
||||||
const res = await fetch('/api/upload', {
|
const res = await fetch('/api/upload', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Token': token,
|
'Authorization': token,
|
||||||
'Generator': generator,
|
'Generator': generator,
|
||||||
'PreserveFileName': preserve ? 'true' : ''
|
'PreserveFileName': preserve ? 'true' : ''
|
||||||
},
|
},
|
||||||
|
|
|
@ -7,11 +7,11 @@ import prisma from 'lib/prisma';
|
||||||
async function handler(req: NextApiReq, res: NextApiRes) {
|
async function handler(req: NextApiReq, res: NextApiRes) {
|
||||||
if (req.method !== 'POST') return res.forbid('Invalid method');
|
if (req.method !== 'POST') return res.forbid('Invalid method');
|
||||||
const usr = await req.user();
|
const usr = await req.user();
|
||||||
if (!(req.headers.token || usr)) return res.forbid('Unauthorized');
|
if (!(req.headers.authorization || usr)) return res.forbid('Unauthorized');
|
||||||
if (!config.shortener.allow_vanity) return res.forbid('Vanity URLs are not allowed');
|
if (!config.shortener.allow_vanity) return res.forbid('Vanity URLs are not allowed');
|
||||||
const user = await prisma.user.findFirst({
|
const user = await prisma.user.findFirst({
|
||||||
where: {
|
where: {
|
||||||
token: req.headers.token
|
token: req.headers.authorization
|
||||||
}
|
}
|
||||||
}) || usr;
|
}) || usr;
|
||||||
if (!user) return res.forbid('Unauthorized');
|
if (!user) return res.forbid('Unauthorized');
|
||||||
|
|
|
@ -14,10 +14,10 @@ const uploader = multer({
|
||||||
|
|
||||||
async function handler(req: NextApiReq, res: NextApiRes) {
|
async function handler(req: NextApiReq, res: NextApiRes) {
|
||||||
if (req.method !== 'POST') return res.forbid('Invalid method');
|
if (req.method !== 'POST') return res.forbid('Invalid method');
|
||||||
if (!req.headers.token) return res.forbid('Unauthorized');
|
if (!req.headers.authorization) return res.forbid('Unauthorized');
|
||||||
const user = await prisma.user.findFirst({
|
const user = await prisma.user.findFirst({
|
||||||
where: {
|
where: {
|
||||||
token: req.headers.token
|
token: req.headers.authorization
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!user) return res.forbid('Unauthorized');
|
if (!user) return res.forbid('Unauthorized');
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Box, Button, Flex, FormControl, FormErrorMessage, FormLabel, Heading, Text, useColorModeValue, useToast, VStack } from '@chakra-ui/react';
|
import { Box, Button, Center, FormControl, FormErrorMessage, FormLabel, Heading, Text, useColorModeValue, useToast, VStack } from '@chakra-ui/react';
|
||||||
import IconTextbox from 'components/IconTextbox';
|
import IconTextbox from 'components/IconTextbox';
|
||||||
import PasswordBox from 'components/PasswordBox';
|
import PasswordBox from 'components/PasswordBox';
|
||||||
import { Field, Form, Formik } from 'formik';
|
import { Field, Form, Formik } from 'formik';
|
||||||
|
@ -48,19 +48,14 @@ export default function Login() {
|
||||||
isClosable: true,
|
isClosable: true,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
const bg = useColorModeValue('gray.100', 'gray.700');
|
|
||||||
const shadow = useColorModeValue('outline', 'dark-lg');
|
|
||||||
return (
|
return (
|
||||||
<Flex minHeight='100vh' width='full' align='center' justifyContent='center'>
|
<Center h='100vh'>
|
||||||
<Box
|
<Box
|
||||||
p={4}
|
|
||||||
bg={bg}
|
|
||||||
width={250}
|
|
||||||
justify='flex-end'
|
|
||||||
align='center'
|
|
||||||
borderRadius={6}
|
borderRadius={6}
|
||||||
boxShadow={shadow}
|
p={4}
|
||||||
>
|
w={300}
|
||||||
|
bg={useColorModeValue('gray.100', 'gray.700')}
|
||||||
|
boxShadow={useColorModeValue('outline', 'dark-lg')}>
|
||||||
<Formik initialValues={{ username: '', password: '' }} validationSchema={schema}
|
<Formik initialValues={{ username: '', password: '' }} validationSchema={schema}
|
||||||
onSubmit={(values, actions) => onSubmit(actions, values)}
|
onSubmit={(values, actions) => onSubmit(actions, values)}
|
||||||
>
|
>
|
||||||
|
@ -100,7 +95,7 @@ export default function Login() {
|
||||||
)}
|
)}
|
||||||
</Formik>
|
</Formik>
|
||||||
</Box>
|
</Box>
|
||||||
</Flex>
|
</Center>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue