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/require-render-return': 'error',
|
||||
'react/style-prop-object': 'warn',
|
||||
'@next/next/no-img-element': 'off',
|
||||
'react/no-find-dom-node': 'off'
|
||||
'@next/next/no-img-element': 'off'
|
||||
}
|
||||
};
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
yarn install # or npm install
|
||||
cp config.example.toml config.toml
|
||||
nano config.toml # edit the config file
|
||||
yarn build # or npm build
|
||||
yarn build # or npm run build
|
||||
yarn start # or npm start
|
||||
```
|
||||
|
||||
|
@ -89,7 +89,7 @@
|
|||
- Discord bot
|
||||
|
||||
### 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
|
||||
- Docker support
|
||||
|
|
|
@ -16,7 +16,7 @@ export default function ShareXDialog({ open, onClose, token }) {
|
|||
RequestMethod: 'POST',
|
||||
RequestURL: `${apiUrl}/upload`,
|
||||
Headers: {
|
||||
Token: token,
|
||||
Authorization: token,
|
||||
Generator: generator,
|
||||
PreserveFileName: preserveFileName ? 'true' : ''
|
||||
},
|
||||
|
@ -34,7 +34,7 @@ export default function ShareXDialog({ open, onClose, token }) {
|
|||
RequestMethod: 'POST',
|
||||
RequestURL: `${apiUrl}/shorten`,
|
||||
Headers: {
|
||||
Token: token
|
||||
Authorization: token
|
||||
},
|
||||
Body: 'FormURLEncoded',
|
||||
Arguments: {
|
||||
|
|
|
@ -29,7 +29,7 @@ export default function Upload() {
|
|||
const res = await fetch('/api/upload', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Token': token,
|
||||
'Authorization': token,
|
||||
'Generator': generator,
|
||||
'PreserveFileName': preserve ? 'true' : ''
|
||||
},
|
||||
|
|
|
@ -7,11 +7,11 @@ import prisma from 'lib/prisma';
|
|||
async function handler(req: NextApiReq, res: NextApiRes) {
|
||||
if (req.method !== 'POST') return res.forbid('Invalid method');
|
||||
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');
|
||||
const user = await prisma.user.findFirst({
|
||||
where: {
|
||||
token: req.headers.token
|
||||
token: req.headers.authorization
|
||||
}
|
||||
}) || usr;
|
||||
if (!user) return res.forbid('Unauthorized');
|
||||
|
|
|
@ -14,10 +14,10 @@ const uploader = multer({
|
|||
|
||||
async function handler(req: NextApiReq, res: NextApiRes) {
|
||||
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({
|
||||
where: {
|
||||
token: req.headers.token
|
||||
token: req.headers.authorization
|
||||
}
|
||||
});
|
||||
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 PasswordBox from 'components/PasswordBox';
|
||||
import { Field, Form, Formik } from 'formik';
|
||||
|
@ -48,19 +48,14 @@ export default function Login() {
|
|||
isClosable: true,
|
||||
});
|
||||
};
|
||||
const bg = useColorModeValue('gray.100', 'gray.700');
|
||||
const shadow = useColorModeValue('outline', 'dark-lg');
|
||||
return (
|
||||
<Flex minHeight='100vh' width='full' align='center' justifyContent='center'>
|
||||
<Center h='100vh'>
|
||||
<Box
|
||||
p={4}
|
||||
bg={bg}
|
||||
width={250}
|
||||
justify='flex-end'
|
||||
align='center'
|
||||
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}
|
||||
onSubmit={(values, actions) => onSubmit(actions, values)}
|
||||
>
|
||||
|
@ -100,7 +95,7 @@ export default function Login() {
|
|||
)}
|
||||
</Formik>
|
||||
</Box>
|
||||
</Flex>
|
||||
</Center>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue