fix: url encode password query
This commit is contained in:
parent
2ef4a52be0
commit
e1003d4bb6
2 changed files with 4 additions and 2 deletions
|
@ -17,7 +17,9 @@ async function handler(req: NextApiReq, res: NextApiRes) {
|
|||
if (!file) return res.notFound('image not found');
|
||||
if (!password) return res.badRequest('no password provided');
|
||||
|
||||
const valid = await checkPassword(password as string, file.password);
|
||||
const decoded = decodeURIComponent(password as string);
|
||||
|
||||
const valid = await checkPassword(decoded, file.password);
|
||||
if (!valid) return res.badRequest('wrong password');
|
||||
|
||||
const data = await datasource.get(file.name);
|
||||
|
|
|
@ -32,7 +32,7 @@ export default function EmbeddedFile({
|
|||
file.createdAt = new Date(file ? file.createdAt : 0);
|
||||
|
||||
const check = async () => {
|
||||
const res = await fetch(`/api/auth/image?id=${file.id}&password=${password}`);
|
||||
const res = await fetch(`/api/auth/image?id=${file.id}&password=${encodeURIComponent(password)}`);
|
||||
|
||||
if (res.ok) {
|
||||
setError('');
|
||||
|
|
Loading…
Add table
Reference in a new issue