Removed viewing all users images (bug)

This commit is contained in:
dicedtomatoreal
2020-04-26 13:28:59 -07:00
parent 41aaeccaed
commit fca8c99bcb
2 changed files with 16 additions and 22 deletions

View File

@@ -96,18 +96,12 @@ export class APIController {
}
}
@Get('images')
private async images(req: Request, res: Response) {
const all = await this.orm.repos.image.find();
return res.status(200).json(all)
}
@Get('images')
@Get('images/user')
@Middleware(cookiesForAPI)
private async imagesUser(req: Request, res: Response) {
const userId = req.query.user;
const all = await this.orm.repos.image.find({ where: { user: userId }, order: { id: 'ASC' }});
return res.status(200).json(all)
const all = await this.orm.repos.image.find({ where: { user: req.session.user.id }, order: { id: 'ASC' } });
return res.status(200).json(all);
}
@Delete('images')

View File

@@ -209,18 +209,18 @@
document.getElementById('updateImages').addEventListener('click', async () => {
document.getElementById('typexImages').innerHTML = '';
const res = await fetch('/api/images?user=' + "<%=user.id%>", {
const res = await fetch('/api/images/user', {
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
'Content-Type': 'application/json'
}
});
try {
const json = await res.json();
if (json.error || json.code) return showAlert('error', json.error)
else {
json.forEach(image => {
$('#typexImages').append(`
try {
const json = await res.json();
if (json.error || json.code) return showAlert('error', json.error)
else {
json.forEach(image => {
$('#typexImages').append(`
<div class="card typex-image-actions typex-image-buttons"
style="background-color: transparent;">
<img class="card-img-top" src="${image.url}" onclick="window.location.href='${image.url}'"/>
@@ -228,11 +228,11 @@
value="${image.id}" />
</div>
`)
});
}
} catch (e) {
console.error(e)
});
}
} catch (e) {
console.error(e)
}
});
const copyText = (text) => {